(std11-parse-ascii-token): Use function
[elisp/mu-cite.git] / std11.el
index c13f545..5c06146 100644 (file)
--- a/std11.el
+++ b/std11.el
@@ -4,7 +4,7 @@
 
 ;; Author:   MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Keywords: mail, news, RFC 822, STD 11
-;; Version: $Id: std11.el,v 0.27 1996-09-03 09:22:23 morioka Exp $
+;; Version: $Id: std11.el,v 0.33 1996-09-14 08:42:39 morioka Exp $
 
 ;; This file is part of MU (Message Utilities).
 
@@ -194,6 +194,53 @@ If BOUNDARY is not nil, it is used as message header separator.
        dest))))
 
 
+;;; @ quoted-string
+;;;
+
+(defconst std11-non-qtext-char-list '(?\" ?\\ ?\r ?\n))
+
+(defun std11-wrap-as-quoted-string (string)
+  "Wrap STRING as RFC 822 quoted-string. [std11.el]"
+  (concat "\""
+         (mapconcat (function
+                     (lambda (chr)
+                       (if (memq chr std11-non-qtext-char-list)
+                           (concat "\\" (char-to-string chr))
+                         (char-to-string chr)
+                         )
+                       )) string "")
+         "\""))
+
+(defun std11-strip-quoted-pair (str)
+  (let ((dest "")
+       (i 0)
+       (len (length str))
+       chr flag)
+    (while (< i len)
+      (setq chr (aref str i))
+      (if (or flag (not (eq chr ?\\)))
+         (progn
+           (setq dest (concat dest (char-to-string chr)))
+           (setq flag nil)
+           )
+       (setq flag t)
+       )
+      (setq i (+ i 1))
+      )
+    dest))
+
+(defun std11-strip-quoted-string (string)
+  "Strip quoted-string STRING. [std11.el]"
+  (std11-strip-quoted-pair
+   (let ((max (1- (length string))))
+     (if (and (eq (aref string 0) ?\")
+             (eq (aref string max) ?\")
+             )
+        (substring string 1 max)
+       string)
+     )))
+
+
 ;;; @ composer
 ;;;