10 (defconst mel-ccl-4-table
13 (defconst mel-ccl-16-table
14 '( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
16 (defconst mel-ccl-28-table
17 '( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
18 16 17 18 19 20 21 22 23 24 25 26 27))
20 (defconst mel-ccl-64-table
21 '( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
22 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
23 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
24 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63))
26 (defconst mel-ccl-256-table
27 '( 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
28 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
29 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
30 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
31 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
32 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
33 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
34 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
35 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
36 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
37 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
38 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
39 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
40 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
41 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
42 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255))
44 (defconst mel-ccl-256-to-16-table
45 '(nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
46 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
47 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
48 0 1 2 3 4 5 6 7 8 9 nil nil nil nil nil nil
49 nil 10 11 12 13 14 15 nil nil nil nil nil nil nil nil nil
50 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
51 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
52 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
53 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
54 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
55 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
56 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
57 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
58 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
59 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
60 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil))
62 (defconst mel-ccl-16-to-256-table
63 (mapcar 'char-int "0123456789ABCDEF"))
65 (defconst mel-ccl-high-table
68 (lambda (v) (nth (lsh v -4) mel-ccl-16-to-256-table))
71 (defconst mel-ccl-low-table
74 (lambda (v) (nth (logand v 15) mel-ccl-16-to-256-table))
77 (defconst mel-ccl-u-raw
81 ABCDEFGHIJKLMNOPQRSTUVWXYZ\
82 abcdefghijklmnopqrstuvwxyz\
83 !@#$%&'()*+,-./:;<>@[\\]^`{|}~"))
85 (defconst mel-ccl-c-raw
89 ABCDEFGHIJKLMNOPQRSTUVWXYZ\
90 abcdefghijklmnopqrstuvwxyz\
91 !@#$%&'*+,-./:;<>@[]^`{|}~"))
93 (defconst mel-ccl-p-raw
97 ABCDEFGHIJKLMNOPQRSTUVWXYZ\
98 abcdefghijklmnopqrstuvwxyz\
101 (defconst mel-ccl-256-to-64-table
102 '(nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
103 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
104 nil nil nil nil nil nil nil nil nil nil nil 62 nil nil nil 63
105 52 53 54 55 56 57 58 59 60 61 nil nil nil t nil nil
106 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
107 15 16 17 18 19 20 21 22 23 24 25 nil nil nil nil nil
108 nil 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
109 41 42 43 44 45 46 47 48 49 50 51 nil nil nil nil nil
110 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
111 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
112 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
113 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
114 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
115 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
116 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
117 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil))
119 (defconst mel-ccl-64-to-256-table
122 "ABCDEFGHIJKLMNOPQRSTUVWXYZ\
123 abcdefghijklmnopqrstuvwxyz\
127 (defconst mel-ccl-qp-table
128 [enc enc enc enc enc enc enc enc enc wsp lf enc enc cr enc enc
129 enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc
130 wsp raw raw raw raw raw raw raw raw raw raw raw raw raw raw raw
131 raw raw raw raw raw raw raw raw raw raw raw raw raw enc raw raw
132 raw raw raw raw raw raw raw raw raw raw raw raw raw raw raw raw
133 raw raw raw raw raw raw raw raw raw raw raw raw raw raw raw raw
134 raw raw raw raw raw raw raw raw raw raw raw raw raw raw raw raw
135 raw raw raw raw raw raw raw raw raw raw raw raw raw raw raw enc
136 enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc
137 enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc
138 enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc
139 enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc
140 enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc
141 enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc
142 enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc
143 enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc enc])
153 (define-ccl-program mel-ccl-decode-q
161 ((= r0 (char-int ?_))
163 ((= r0 (char-int ?=))
172 mel-ccl-256-to-16-table)))
179 `((write r0 ,(vconcat
182 (logior (lsh r0 4) v))
186 mel-ccl-256-to-16-table)))
189 `(write-repeat ,r0))))
190 mel-ccl-256-table))))))
194 (defun mel-ccl-encode-q-generic (raw)
203 ((= r0 32) `(write-repeat ?_))
204 ((member r0 raw) `(write-repeat ,r0))
208 (write r0 ,mel-ccl-high-table)
209 (write r0 ,mel-ccl-low-table)
212 ;; On xemacs, generated program counts iso-8859-1 8bit character as 6bytes.
213 (defun mel-ccl-count-q-length (raw)
221 (if (or (= r1 32) (member r1 raw))
222 '((r0 += 1) (repeat))
223 '((r0 += 3) (repeat))))
224 mel-ccl-256-table))))))
228 (define-ccl-program mel-ccl-encode-uq
229 (mel-ccl-encode-q-generic mel-ccl-u-raw))
230 (define-ccl-program mel-ccl-encode-cq
231 (mel-ccl-encode-q-generic mel-ccl-c-raw))
232 (define-ccl-program mel-ccl-encode-pq
233 (mel-ccl-encode-q-generic mel-ccl-p-raw))
235 (define-ccl-program mel-ccl-count-uq
236 (mel-ccl-count-q-length mel-ccl-u-raw))
237 (define-ccl-program mel-ccl-count-cq
238 (mel-ccl-count-q-length mel-ccl-c-raw))
239 (define-ccl-program mel-ccl-count-pq
240 (mel-ccl-count-q-length mel-ccl-p-raw))
246 (defun mel-ccl-decode-b-bit-ex (v)
248 (lsh (logand v (lsh 255 16)) -16)
249 (logand v (lsh 255 8))
250 (lsh (logand v 255) 16)))
252 (defconst mel-ccl-decode-b-0-table
257 (mel-ccl-decode-b-bit-ex (lsh v 18))
259 mel-ccl-256-to-64-table)))
261 (defconst mel-ccl-decode-b-1-table
266 (mel-ccl-decode-b-bit-ex (lsh v 12))
268 mel-ccl-256-to-64-table)))
270 (defconst mel-ccl-decode-b-2-table
275 (mel-ccl-decode-b-bit-ex (lsh v 6))
277 mel-ccl-256-to-64-table)))
279 (defconst mel-ccl-decode-b-3-table
284 (mel-ccl-decode-b-bit-ex v)
286 mel-ccl-256-to-64-table)))
290 (define-ccl-program mel-ccl-decode-b
294 (r4 = r0 ,mel-ccl-decode-b-0-table)
295 (r5 = r1 ,mel-ccl-decode-b-1-table)
297 (r5 = r2 ,mel-ccl-decode-b-2-table)
299 (r5 = r3 ,mel-ccl-decode-b-3-table)
301 (if (r4 & ,(lognot (1- (lsh 1 24))))
303 (if (r4 & ,(lsh 1 24))
304 ((r0 = r1) (r1 = r2) (r2 = r3) (read r3)
305 (r4 >>= 1) (r4 &= ,(logior (lsh 7 24)))
306 (r5 = r3 ,mel-ccl-decode-b-3-table)
311 (if (r4 & ,(lsh 1 25))
312 ((r1 = r2) (r2 = r3) (read r3)
313 (r4 >>= 1) (r4 &= ,(logior (lsh 7 24)))
314 (r5 = r3 ,mel-ccl-decode-b-3-table)
320 (if (r4 & ,(lsh 1 26))
322 (r4 >>= 1) (r4 &= ,(logior (lsh 7 24)))
323 (r5 = r3 ,mel-ccl-decode-b-3-table)
332 (if (r4 & ,(lsh 1 27))
334 (r4 = r3 ,mel-ccl-decode-b-3-table)
339 (r4 = r0 ,mel-ccl-decode-b-0-table)
340 (r5 = r1 ,mel-ccl-decode-b-1-table)
345 ((r5 = r2 ,mel-ccl-decode-b-2-table)
347 (r5 = r3 ,mel-ccl-decode-b-3-table)
358 ((r5 = r2 ,mel-ccl-decode-b-2-table)
371 (write-repeat r4))))))
375 ;; Generated CCL program works not properly on 20.2 because CCL_EOF_BLOCK
377 (defun mel-ccl-encode-base64-generic (&optional quantums-per-line output-crlf terminate-with-newline)
386 `((write ,(nth (lsh r1 -2) mel-ccl-64-to-256-table))
387 (r0 = ,(logand r1 3))))
394 `((write r0 ,(vconcat
397 (nth (logior (lsh r0 4)
399 mel-ccl-64-to-256-table))
401 (r0 = ,(logand r1 15))))
408 `((write r0 ,(vconcat
411 (nth (logior (lsh r0 2)
413 mel-ccl-64-to-256-table))
414 mel-ccl-16-table)))))
420 (nth r1 mel-ccl-64-to-256-table))
423 ,@(when quantums-per-line
424 `((if (r3 == ,quantums-per-line)
425 ((write ,(if output-crlf "\r\n" "\n"))
430 ,(if terminate-with-newline
431 `(if (r3 > 0) (write ,(if output-crlf "\r\n" "\n")))
436 (nth (lsh r0 4) mel-ccl-64-to-256-table))
438 (write ,(if terminate-with-newline
439 (if output-crlf "==\r\n" "==\n")
444 (nth (lsh r0 2) mel-ccl-64-to-256-table))
446 (write ,(if terminate-with-newline
447 (if output-crlf "=\r\n" "=\n")
452 (define-ccl-program mel-ccl-encode-b
453 (mel-ccl-encode-base64-generic))
456 (define-ccl-program mel-ccl-encode-base64-crlf-crlf
457 (mel-ccl-encode-base64-generic 19 t))
459 (define-ccl-program mel-ccl-encode-base64-crlf-lf
460 (mel-ccl-encode-base64-generic 19 nil))
466 ;; Generated CCL program works not properly on 20.2 because CCL_EOF_BLOCK
468 (defun mel-ccl-encode-quoted-printable-generic (input-crlf output-crlf)
471 (r5 = 0) ; previous character is white space
481 (let ((tmp (aref mel-ccl-qp-table r0)))
483 ((eq tmp 'raw) '((r3 = 0) (break))) ; RAW
484 ((eq tmp 'enc) '((r3 = 1) (break))) ; ENC
485 ((eq tmp 'wsp) '((r3 = 2) (break))) ; WSP
486 ((eq tmp 'cr) (if input-crlf
487 '((r3 = 3) (break)) ; CR
488 '((r3 = 1) (break)))) ; ENC
489 ((eq tmp 'lf) (if input-crlf
490 '((r3 = 1) (break)) ; ENC
491 '((r3 = 3) (break)))) ; CRLF
501 (write-read-repeat r0))
508 (write r0 ,mel-ccl-high-table)
510 (write-read-repeat r0 ,mel-ccl-low-table))
513 (write ,(if output-crlf "=\r\n=" "=\n="))
514 (write r0 ,mel-ccl-high-table)
516 (write-read-repeat r0 ,mel-ccl-low-table))
523 (write-read-repeat r0))
525 (write ,(if output-crlf "=\r\n" "=\n"))
527 (write-read-repeat r0))))
531 `((if ((r6 > 73) & r5)
534 (write ,(if output-crlf "=\r\n" "=\n"))))
541 (write ,(if output-crlf "=\r\n" "=\n"))
542 ,@(if output-crlf '((write ?\r)) '())
543 (write-read-repeat r0))
544 ;; noWSP ; r0:r3=CRLF
547 ,@(if output-crlf '((write ?\r)) '())
548 (write-read-repeat r0)))
550 ;; r0:r3={RAW,ENC,CR}
553 (lambda (after-cr after-raw-enc)
566 ;; r5=WSP ; CR:r3=CR r0=LF
569 (write ,(if output-crlf "=\r\n\r\n" "=\n\n"))
573 ;; r5=noWSP ; CR:r3=CR r0=LF
576 (write ,(if output-crlf "\r\n" "\n"))
596 (write ,(if output-crlf "=0D\r\n" "=0D\n"))
603 (write ,(if output-crlf "=\r\n=0D=0D" "=\n=0D=0D"))
605 ;; CR:r3=CR r0=noLFnorCR
608 (write ,(if output-crlf "=\r\n=0D" "=\n=0D"))
612 (write ,(if output-crlf "=\r\n=0D" "=\n=0D"))
615 (lambda (after-newline after-cr-nolf after-nonewline)
620 ;; r0:r3={RAW,ENC} r1
622 ;; r0:r3={RAW,ENC} r1=CR
625 ;; r0:r3={RAW,ENC} CR r1
627 ;; r0:r3=RAW CR r1=LF
629 ;; r0:r3=RAW CR r1=noLF
631 ;; r0:r3={RAW,ENC} r1:noCR
636 ;; r0:r3={RAW,ENC} r1
638 ;; r0:r3={RAW,ENC} r1=CRLF
640 ;; r0:r3={RAW,ENC} r1:noCRLF
642 ;; r0:r3={RAW,ENC} CR r1=LF
643 ;; r0:r3={RAW,ENC} r1=CRLF
648 ;; r0:r3=RAW CR r1=LF
651 (write ,(if output-crlf "\r\n" "\n"))
655 ;; r0:r3=ENC CR r1=LF
658 (write r0 ,mel-ccl-high-table)
659 (write r0 ,mel-ccl-low-table)
660 (write ,(if output-crlf "\r\n" "\n"))
664 ;; r0:r3={RAW,ENC} CR r1=noLF
667 ;; r0:r3=RAW CR r1:noLF
670 (write ,(if output-crlf "=\r\n" "=\n"))
675 ;; r0:r3=ENC CR r1:noLF
678 (write ,(if output-crlf "=\r\n=" "=\n="))
679 (write r0 ,mel-ccl-high-table)
680 (write r0 ,mel-ccl-low-table)
684 ;; r0:r3={RAW,ENC} r1:noCR
685 ;; r0:r3={RAW,ENC} r1:noCRLF
689 ;; r0:r3=RAW r1:noCRLF
692 (write ,(if output-crlf "=\r\n" "=\n"))
697 ;; r0:r3=ENC r1:noCRLF
700 (write ,(if output-crlf "=\r\n=" "=\n="))
701 (write r0 ,mel-ccl-high-table)
702 (write r0 ,mel-ccl-low-table)
707 ( ;(write "[EOF:") (write r4 ,mel-ccl-high-table) (write r4 ,mel-ccl-low-table) (write "]")
716 ;; 3: SOFTBREAK r0:r3=ENC ;
719 ((write ,(if output-crlf "=\r\n" "=\n")) (end))
720 ;; 5: SOFTBREAK r0:r3=WSP ;
721 ((write ,(if output-crlf "=\r\n" "=\n")) (end))
724 ((write "=0D") (end))
725 ((write ,(if output-crlf "=\r\n=0D" "=\n=0D")) (end)))
726 ;; 7: r5=WSP SOFTBREAK CR:r3=CR r0=LF ;
728 ;; 8: r5=noWSP CR:r3=CR r0=LF ;
730 ;; 9: (r6=73) ; CR:r3=CR r0=CR
731 ((write ,(if output-crlf "=\r\n=0D=0D" "=\n=0D=0D")) (end))
732 ;; 10: (r6=73) CR:r3=CR CR LF ;
734 ;; 11: ; r0:r3={RAW,ENC}
739 (write r0 ,mel-ccl-high-table)
740 (write r0 ,mel-ccl-low-table)
742 ;; 12: ; r0:r3={RAW,ENC} r1=CR
746 ((write ,(if output-crlf "=\r\n" "=\n"))
751 ((write ,(if output-crlf "=\r\n=" "=\n="))
752 (write r0 ,mel-ccl-high-table)
753 (write r0 ,mel-ccl-low-table)
756 ;; 13: r0:r3=RAW CR LF ;
757 ;; 13: r0:r3=RAW CRLF ;
759 ;; 14: r0:r3=ENC CR LF ;
760 ;; 14: r0:r3=ENC CRLF ;
765 (defun mel-ccl-decode-quoted-printable-generic (input-crlf output-crlf)
773 (let ((tmp (aref mel-ccl-qp-table r0)))
775 ((eq tmp 'raw) `(write-read-repeat r0))
776 ((eq tmp 'wsp) (if (eq r0 (char-int ? ))
786 ;; hard line break found.
789 (write-read-repeat r0))
790 '(write-read-repeat r0))
792 ;; invalid control character (bare CR) found.
793 ;; -> ignore it and rescan from r0.
796 ;; invalid character (bare CR) found.
803 ;; invalid character (bare LF) found.
808 ;; hard line break found.
811 (write-read-repeat r0))
812 '(write-read-repeat r0))))
813 ((eq r0 (char-int ?=))
818 (if ((r0 == ? ) | r1)
820 ;; Skip transport-padding.
821 ;; It should check CR LF after
822 ;; transport-padding.
829 ;; '=' [\t ]* r0:[^\t ]
835 ((eq r0 (char-int ?\r))
837 ;; '=' [\t ]* r0='\r'
839 ;; '=' [\t ]* '\r' r0
841 ;; '=' [\t ]* '\r' r0='\n'
842 ;; soft line break found.
845 ;; '=' [\t ]* '\r' r0:[^\n]
847 ;; output "=" and rescan from r0.
850 ;; '=' [\t ]* r0='\r'
851 ;; invalid input (bare CR found) ->
852 ;; output "=" and rescan from next.
856 ((eq r0 (char-int ?\n))
858 ;; '=' [\t ]* r0='\n'
859 ;; invalid input (bare LF found) ->
860 ;; output "=" and rescan from next.
864 ;; '=' [\t ]* r0='\r\n'
865 ;; soft line break found.
868 ((setq tmp (nth r0 mel-ccl-256-to-16-table))
869 ;; '=' [\t ]* r0:[0-9A-F]
870 ;; upper nibble of hexadecimal digit found.
874 ;; '=' [\t ]* r0:[^\r0-9A-F]
876 ;; output "=" and rescan from r0.
880 ;; '=' [\t ]* r1:r0:[0-9A-F]
885 (if (setq tmp (nth r2 mel-ccl-256-to-16-table))
886 ;; '=' [\t ]* r1:r0:[0-9A-F] r2:[0-9A-F]
892 (logior (lsh r0 4) tmp))
894 ;; '=' [\t ]* r1:r0:[0-9A-F] r2:[^0-9A-F]
899 ;; '=' [\t ]* r1:r0:[0-9A-F] r2:[^0-9A-F]
901 ;; output "=" with hex digit and rescan from r2.
907 ;; invalid character found.
918 (let ((reg (aref [r1 r2 r3 r4 r5] regnum)))
931 ((r6 = ,(+ (* regnum 28) bit))
935 (,reg |= ,(lsh 1 bit))
937 ((r6 = ,(+ (* regnum 28) bit))
941 ;; white space buffer exhaust.
942 ;; error: line length limit (76bytes) violation.
943 ;; -> ignore these white spaces.
949 ;; trailing white spaces found.
950 ;; -> ignore these white spacs.
951 ((write ,(if output-crlf "\r\n" "\n"))
954 ;; [\t ]* \r r0:[^\n]
955 ;; error: bare CR found.
956 ;; -> output white spaces and ignore bare CR.
959 ;; middle white spaces found.
962 ;; trailing white spaces found.
963 ;; -> ignore these white spacs.
964 ((write ,(if output-crlf "\r\n" "\n"))
968 ;; middle white spaces found.
974 (let ((reg (aref [r1 r2 r3 r4 r5] regnum)))
979 `((if (,reg & ,(lsh 1 bit))
982 (if (r6 == ,(+ (* regnum 28) bit 1))
991 (define-ccl-program mel-ccl-encode-quoted-printable-crlf-crlf
992 (mel-ccl-encode-quoted-printable-generic t t))
994 (define-ccl-program mel-ccl-encode-quoted-printable-crlf-lf
995 (mel-ccl-encode-quoted-printable-generic t nil))
997 (define-ccl-program mel-ccl-encode-quoted-printable-lf-crlf
998 (mel-ccl-encode-quoted-printable-generic nil t))
1000 (define-ccl-program mel-ccl-encode-quoted-printable-lf-lf
1001 (mel-ccl-encode-quoted-printable-generic nil nil))
1003 (define-ccl-program mel-ccl-decode-quoted-printable-crlf-crlf
1004 (mel-ccl-decode-quoted-printable-generic t t))
1006 (define-ccl-program mel-ccl-decode-quoted-printable-crlf-lf
1007 (mel-ccl-decode-quoted-printable-generic t nil))
1009 (define-ccl-program mel-ccl-decode-quoted-printable-lf-crlf
1010 (mel-ccl-decode-quoted-printable-generic nil t))
1012 (define-ccl-program mel-ccl-decode-quoted-printable-lf-lf
1013 (mel-ccl-decode-quoted-printable-generic nil nil))
1019 (make-ccl-coding-system
1020 'mel-ccl-uq-rev ?Q "MIME Q-encoding in unstructured field (reversed)"
1021 'mel-ccl-encode-uq 'mel-ccl-decode-q)
1023 (make-ccl-coding-system
1024 'mel-ccl-cq-rev ?Q "MIME Q-encoding in comment (reversed)"
1025 'mel-ccl-encode-cq 'mel-ccl-decode-q)
1027 (make-ccl-coding-system
1028 'mel-ccl-pq-rev ?Q "MIME Q-encoding in phrase (reversed)"
1029 'mel-ccl-encode-pq 'mel-ccl-decode-q)
1031 (make-ccl-coding-system
1032 'mel-ccl-b-rev ?B "MIME B-encoding (reversed)"
1033 'mel-ccl-encode-b 'mel-ccl-decode-b)
1035 (make-ccl-coding-system
1036 'mel-ccl-quoted-printable-crlf-crlf-rev
1037 ?Q "MIME Quoted-Printable-encoding (reversed)"
1038 'mel-ccl-encode-quoted-printable-crlf-crlf
1039 'mel-ccl-decode-quoted-printable-crlf-crlf)
1041 (make-ccl-coding-system
1042 'mel-ccl-quoted-printable-lf-crlf-rev
1043 ?Q "MIME Quoted-Printable-encoding (LF encoding) (reversed)"
1044 'mel-ccl-encode-quoted-printable-crlf-lf
1045 'mel-ccl-decode-quoted-printable-lf-crlf)
1047 (make-ccl-coding-system
1048 'mel-ccl-quoted-printable-crlf-lf-rev
1049 ?Q "MIME Quoted-Printable-encoding (LF internal) (reversed)"
1050 'mel-ccl-encode-quoted-printable-lf-crlf
1051 'mel-ccl-decode-quoted-printable-crlf-lf)
1053 (make-ccl-coding-system
1054 'mel-ccl-quoted-printable-lf-lf-rev
1055 ?Q "MIME Quoted-Printable-encoding (LF encoding) (LF internal) (reversed)"
1056 'mel-ccl-encode-quoted-printable-lf-lf
1057 'mel-ccl-decode-quoted-printable-lf-lf)
1059 (make-ccl-coding-system
1060 'mel-ccl-base64-crlf-rev
1061 ?B "MIME Base64-encoding (reversed)"
1062 'mel-ccl-encode-base64-crlf-crlf
1065 (make-ccl-coding-system
1066 'mel-ccl-base64-lf-rev
1067 ?B "MIME Base64-encoding (LF encoding) (reversed)"
1068 'mel-ccl-encode-base64-crlf-lf
1075 (unless (and (boundp 'ccl-encoder-eof-block-is-broken)
1076 ccl-encoder-eof-block-is-broken)
1078 (defun base64-ccl-encode-string (string)
1079 "Encode STRING with base64 encoding."
1080 (decode-coding-string string 'mel-ccl-base64-lf-rev))
1082 (defun base64-ccl-encode-region (start end)
1083 "Encode region from START to END with base64 encoding."
1085 (decode-coding-region start end 'mel-ccl-base64-lf-rev))
1087 (defun base64-ccl-insert-encoded-file (filename)
1088 "Encode contents of file FILENAME to base64, and insert the result."
1089 (interactive (list (read-file-name "Insert encoded file: ")))
1090 (let ((coding-system-for-read 'mel-ccl-b-rev))
1091 (insert-file-contents filename)))
1095 (defun base64-ccl-decode-string (string)
1096 "Decode base64 encoded STRING"
1097 (encode-coding-string string 'mel-ccl-b-rev))
1099 (defun base64-ccl-decode-region (start end)
1100 "Decode base64 encoded the region from START to END."
1102 (encode-coding-region start end 'mel-ccl-b-rev))
1104 (defun base64-ccl-write-decoded-region (start end filename)
1105 "Decode the region from START to END and write out to FILENAME."
1107 (list (region-beginning) (region-end)
1108 (read-file-name "Write decoded region to file: ")))
1109 (let ((coding-system-for-write 'mel-ccl-b-rev))
1110 (write-region start end filename)))
1113 ;;; @ quoted-printable
1116 (unless (and (boundp 'ccl-encoder-eof-block-is-broken)
1117 ccl-encoder-eof-block-is-broken)
1119 (defun quoted-printable-ccl-encode-string (string)
1120 "Encode STRING with quoted-printable encoding."
1121 (decode-coding-string
1123 'mel-ccl-quoted-printable-lf-lf-rev))
1125 (defun quoted-printable-ccl-encode-region (start end)
1126 "Encode the region from START to END with quoted-printable
1129 (decode-coding-region start end 'mel-ccl-quoted-printable-lf-lf-rev))
1131 (defun quoted-printable-ccl-insert-encoded-file (filename)
1132 "Encode contents of the file named as FILENAME, and insert it."
1133 (interactive (list (read-file-name "Insert encoded file: ")))
1134 (let ((coding-system-for-read 'mel-ccl-quoted-printable-lf-lf-rev))
1135 (insert-file-contents filename)))
1139 (defun quoted-printable-ccl-decode-string (string)
1140 "Decode quoted-printable encoded STRING."
1141 (encode-coding-string
1143 'mel-ccl-quoted-printable-lf-lf-rev))
1145 (defun quoted-printable-ccl-decode-region (start end)
1146 "Decode the region from START to END with quoted-printable
1149 (encode-coding-region start end 'mel-ccl-quoted-printable-lf-lf-rev))
1151 (defun quoted-printable-ccl-write-decoded-region
1152 (start end filename)
1153 "Decode quoted-printable encoded current region and write out to FILENAME."
1155 (list (region-beginning) (region-end)
1156 (read-file-name "Write decoded region to file: ")))
1157 (let ((coding-system-for-write 'mel-ccl-quoted-printable-lf-lf-rev))
1158 (write-region start end filename)))
1164 (defun q-encoding-ccl-encode-string (string &optional mode)
1165 "Encode STRING to Q-encoding of encoded-word, and return the result.
1166 MODE allows `text', `comment', `phrase' or nil. Default value is
1168 (decode-coding-string
1171 ((eq mode 'text) 'mel-ccl-uq-rev)
1172 ((eq mode 'comment) 'mel-ccl-cq-rev)
1173 (t 'mel-ccl-pq-rev))))
1175 (defun q-encoding-ccl-decode-string (string)
1176 "Decode Q encoded STRING and return the result."
1177 (encode-coding-string
1181 (unless running-xemacs
1182 (defun q-encoding-ccl-encoded-length (string &optional mode)
1183 "Encode STRING to Q-encoding of encoded-word, and return the result.
1184 MODE allows `text', `comment', `phrase' or nil. Default value is
1186 (let ((status [nil nil nil nil nil nil nil nil nil]))
1187 (fillarray status nil)
1188 (ccl-execute-on-string
1190 ((eq mode 'text) 'mel-ccl-count-uq)
1191 ((eq mode 'comment) 'mel-ccl-count-cq)
1192 (t 'mel-ccl-count-pq))
1204 (let ((str0 "a\f \t\r
1205 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r
1206 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r
1207 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r
1208 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\f\r
1209 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\f\r
1210 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\f\r
1214 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \r
1215 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \r
1216 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \r
1217 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \r
1220 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\rccc\r
1221 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\r\r\nccc\r
1222 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\r\rccc\r
1223 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\rccc\r
1224 dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\r\neee\r
1225 dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\reee\r
1226 ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeee\r
1228 str1 encoded decoded)
1229 (setq str1 (ew-crlf-to-lf str0)
1232 (decode-coding-string
1234 'mel-ccl-quoted-printable-crlf-crlf-rev)
1235 (decode-coding-string
1237 'mel-ccl-quoted-printable-lf-crlf-rev)
1238 (decode-coding-string
1240 'mel-ccl-quoted-printable-crlf-lf-rev)
1241 (decode-coding-string
1243 'mel-ccl-quoted-printable-lf-lf-rev))
1246 (encode-coding-string
1248 'mel-ccl-quoted-printable-crlf-crlf-rev)
1249 (encode-coding-string
1251 'mel-ccl-quoted-printable-lf-crlf-rev)
1252 (encode-coding-string
1254 'mel-ccl-quoted-printable-crlf-lf-rev)
1255 (encode-coding-string
1257 'mel-ccl-quoted-printable-lf-lf-rev)))
1259 (string= str0 (nth 0 decoded))
1260 (string= str0 (nth 1 decoded))
1261 (string= str1 (nth 2 decoded))
1262 (string= str1 (nth 3 decoded))))
1265 (defun make-ccl-coding-system (name mnemonic doc-string decoder encoder)
1267 name 'ccl doc-string
1268 (list 'mnemonic (char-to-string mnemonic)
1269 'decode (symbol-value decoder)
1270 'encode (symbol-value encoder))))