/[emacs]/emacs/lisp/international/mule.el
ViewVC logotype

Diff of /emacs/lisp/international/mule.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.141.2.27 by handa, Wed May 28 11:41:17 2003 UTC revision 1.141.2.28 by handa, Fri May 30 06:02:00 2003 UTC
# Line 1021  This alist is used to decode an extened Line 1021  This alist is used to decode an extened
1021  (defvar ctext-non-standard-designations-alist  (defvar ctext-non-standard-designations-alist
1022    '(("$(0" . (big5 "big5-0" 2))    '(("$(0" . (big5 "big5-0" 2))
1023      ("$(1" . (big5 "big5-0" 2))      ("$(1" . (big5 "big5-0" 2))
1024      ("-V"  . (t "iso8859-10" 1))      ;; The following are actually standard; generating extended
1025      ("-Y"  . (t "iso8859-13" 1))      ;; segments for them is wrong and screws e.g. Latin-9 users.
1026      ("-_"  . (t "iso8859-14" 1))      ;; ("-V"  . (t "iso8859-10" 1))
1027      ("-b"  . (t "iso8859-15" 1))      ;; ("-Y"  . (t "iso8859-13" 1))
1028      ("-f"  . (t "iso8859-16" 1)))      ;; ("-_"  . (t "iso8859-14" 1))
1029    "Alist of ctext control sequences that introduce character sets      ;; ("-b"  . (t "iso8859-15" 1))
1030  which are not in the list of approved COMPOUND TEXT encodings, and the      ;; ("-f"  . (t "iso8859-16" 1))
1031  corresponding coding system, identifier string, and number of octets      )
1032  per encoded character.    "Alist of ctext control sequences that introduce character sets which
1033    are not in the list of approved encodings, and the corresponding
1034    coding system, identifier string, and number of octets per encoded
1035    character.
1036    
1037  Each element has the form (CTLSEQ . (ENCODING CHARSET NOCTETS)).  CTLSEQ  Each element has the form (CTLSEQ . (ENCODING CHARSET NOCTETS)).  CTLSEQ
1038  is the control sequence (sans the leading ESC) that introduces the character  is the control sequence (sans the leading ESC) that introduces the character
# Line 1037  set in the text encoded by compound-text Line 1040  set in the text encoded by compound-text
1040  symbol; if it is t, it means that the ctext coding system already encodes  symbol; if it is t, it means that the ctext coding system already encodes
1041  the text correctly, and only the leading control sequence needs to be altered.  the text correctly, and only the leading control sequence needs to be altered.
1042  If ENCODING is a coding system, we need to re-encode the text with that  If ENCODING is a coding system, we need to re-encode the text with that
1043  coding system.  CHARSET is the ICCCM name of the charset we need to put into  coding system.  CHARSET is the name of the charset we need to put into
1044  the leading control sequence.  NOCTETS is the number of octets (bytes) that  the leading control sequence.  NOCTETS is the number of octets (bytes) that
1045  encode each character in this charset.  NOCTETS can be 0 (meaning the number  encode each character in this charset.  NOCTETS can be 0 (meaning the number
1046  of octets per character is variable), 1, 2, 3, or 4.")  of octets per character is variable), 1, 2, 3, or 4.")
# Line 1049  If FROM is a string, or if the current b Line 1052  If FROM is a string, or if the current b
1052  by run_pre_post_conversion_on_str, generate a new temp buffer, insert the  by run_pre_post_conversion_on_str, generate a new temp buffer, insert the
1053  text, and convert it in the temporary buffer.  Otherwise, convert in-place."  text, and convert it in the temporary buffer.  Otherwise, convert in-place."
1054    (save-match-data    (save-match-data
1055      (save-restriction      ;; Setup a working buffer if necessary.
1056        (narrow-to-region from to)      (when (stringp from)
1057        (goto-char from)        (set-buffer (generate-new-buffer " *temp"))
1058        (encode-coding-region from to 'ctext-no-compositions)        (set-buffer-multibyte (multibyte-string-p from))
1059        (set-buffer-multibyte nil)        (insert from))
1060        ;; Replace ISO-2022 charset designations with extended segments,  
1061        ;; for those charsets that are not part of the official X      ;; Now we can encode the whole buffer.
1062        ;; registry.      (let ((case-fold-search nil)
1063        (let ((case-fold-search nil)            last-coding-system-used
1064              pos posend desig encode-info encoding chset noctets textlen)            pos posend desig encode-info encoding chset noctets textlen)
1065          ;; The regexp below finds the leading sequences for big5 and        (goto-char (point-min))
1066          ;; iso8859-1[03-6] charsets.        ;; At first encode the whole buffer.
1067          (while (re-search-forward "\e\\(\$([01]\\|-[VY_bf]\\)" nil 'move)        (encode-coding-region (point-min) (point-max) 'ctext-no-compositions)
1068            (setq pos (match-beginning 0)        ;; Then replace ISO-2022 charset designations with extended
1069                  posend (point)        ;; segments, for those charsets that are not part of the
1070                  desig (match-string 1)        ;; official X registry.  The regexp below finds the leading
1071                  encode-info (cdr (assoc desig        ;; sequences for big5.
1072                                          ctext-non-standard-designations-alist))        (while (re-search-forward "\e\\(\$([01]\\)" nil 'move)
1073                  encoding (car encode-info)          (setq pos (match-beginning 0)
1074                  chset (cadr encode-info)                posend (point)
1075                  noctets (car (cddr encode-info)))                desig (match-string 1)
1076            (skip-chars-forward "^\e")                encode-info (cdr (assoc desig
1077            (cond                                        ctext-non-standard-designations-alist))
1078             ((eq encoding t) ; only the leading sequence needs to be changed                encoding (car encode-info)
1079              (setq textlen (+ (- (point) posend) (length chset) 1))                chset (cadr encode-info)
1080              ;; Generate the ICCCM control sequence for an extended segment.                noctets (car (cddr encode-info)))
1081              (replace-match (format "\e%%/%d%c%c%s\
"
         (skip-chars-forward "^\e")
1082                                     noctets          (cond
1083                                     (+ (/ textlen 128) 128)           ((eq encoding t) ; only the leading sequence needs to be changed
1084                                     (+ (% textlen 128) 128)            (setq textlen (+ (- (point) posend) (length chset) 1))
1085                                     chset)            ;; Generate the control sequence for an extended segment.
1086                             t t))            (replace-match (string-to-multibyte (format "\e%%/%d%c%c%s\
"
1087             ((coding-system-p encoding) ; need to recode the entire segment...                                                        noctets
1088              (decode-coding-region pos (point) 'ctext-no-compositions)                                                        (+ (/ textlen 128) 128)
1089              (encode-coding-region pos (point) encoding)                                                        (+ (% textlen 128) 128)
1090              (setq textlen (+ (- (point) pos) (length chset) 1))                                                        chset))
1091              (save-excursion                           t t))
1092                (goto-char pos)           ((coding-system-p encoding) ; need to recode the entire segment...
1093                (insert (format "\e%%/%d%c%c%s\
"
           (decode-coding-region pos (point) 'ctext-no-compositions)
1094                                noctets            (encode-coding-region pos (point) encoding)
1095                                (+ (/ textlen 128) 128)            (setq textlen (+ (- (point) pos) (length chset) 1))
1096                                (+ (% textlen 128) 128)            (save-excursion
1097                                chset)))))))              (goto-char pos)
1098        (goto-char (point-min)))))              (insert (string-to-multibyte (format "\e%%/%d%c%c%s\
"
1099                                                     noctets
1100                                                     (+ (/ textlen 128) 128)
1101                                                     (+ (% textlen 128) 128)
1102                                                     chset)))))))
1103          (goto-char (point-min))))
1104      ;; Must return nil, as build_annotations_2 expects that.
1105      nil)
1106    
1107  (make-obsolete 'set-coding-priority 'set-coding-system-priority "22.1")  (make-obsolete 'set-coding-priority 'set-coding-system-priority "22.1")
1108    

Legend:
Removed from v.1.141.2.27  
changed lines
  Added in v.1.141.2.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26