-(defun q-encoding-encode-string-for-text (str)
- (mapconcat (function
- (lambda (chr)
- (cond ((eq chr 32) "_")
- ((or (< chr 32) (< 126 chr) (eq chr ?=))
- (quoted-printable-quote-char chr)
- )
- (t (char-to-string chr))
- )))
- str ""))
-
-(defun q-encoding-encode-string-for-comment (str)
- (mapconcat (function
- (lambda (chr)
- (cond ((eq chr 32) "_")
- ((or (< chr 32) (< 126 chr)
- (memq chr '(?= ?\( ?\) ?\\))
- )
- (quoted-printable-quote-char chr)
- )
- (t (char-to-string chr))
- )))
- str ""))
-
-(defun q-encoding-encode-string-for-phrase (str)
- (mapconcat (function
- (lambda (chr)
- (cond ((or (and (<= ?A chr)(<= chr ?Z))
- (and (<= ?a chr)(<= chr ?z))
- (and (<= ?0 chr)(<= chr ?9))
- (memq chr '(?! ?* ?+ ?- ?/))
- )
- (char-to-string chr)
- )
- (t (quoted-printable-quote-char chr))
- )))
- str ""))
-
-(defun q-encoding-encode-string (str &optional mode)
- (cond ((eq mode 'text)
- (q-encoding-encode-string-for-text str)
- )
- ((eq mode 'comment)
- (q-encoding-encode-string-for-comment str)
- )
- ((eq mode 'phrase)
- (q-encoding-encode-string-for-phrase str)
- )
- (t (quoted-printable-encode-string str))
- ))
+(defconst q-encoding-special-chars-alist
+ '((text ?= ?? ?_)
+ (comment ?= ?? ?_ ?\( ?\) ?\\)
+ (phrase ?= ?? ?_ ?\( ?\) ?\\ ?\" ?# ?$ ?% ?& ?' ?, ?. ?/
+ ?: ?\; ?< ?> ?@ ?\[ ?\] ?^ ?` ?{ ?| ?} ?~)
+ ))