comparison lisp/w3/mule-sysdp.el @ 102:a145efe76779 r20-1b3

Import from CVS: tag r20-1b3
author cvs
date Mon, 13 Aug 2007 09:15:49 +0200
parents 441bb1e64a06
children fe104dbd9147
comparison
equal deleted inserted replaced
101:a0ec055d74dd 102:a145efe76779
29 29
30 (defconst mule-retrieval-coding-system 30 (defconst mule-retrieval-coding-system
31 (case mule-sysdep-version 31 (case mule-sysdep-version
32 (2.3 *euc-japan*) 32 (2.3 *euc-japan*)
33 (2.4 'coding-system-euc-japan) 33 (2.4 'coding-system-euc-japan)
34 (3.0 'euc-japan)
34 (xemacs 'euc-japan) 35 (xemacs 'euc-japan)
35 (otherwise nil)) 36 (otherwise nil))
36 "Default retrieval coding system for packages that use this package.") 37 "Default retrieval coding system for packages that use this package.")
37 38
38 (defconst mule-no-coding-system 39 (defconst mule-no-coding-system
39 (case mule-sysdep-version 40 (case mule-sysdep-version
41 (2.3 *noconv*)
40 (2.4 'no-conversion) 42 (2.4 'no-conversion)
41 (2.3 *noconv*) 43 (3.0 'no-conversion)
42 (xemacs 'no-conversion) 44 (xemacs 'no-conversion)
43 (otherwise nil)) 45 (otherwise nil))
44 "Coding system that means no coding system should be used.") 46 "Coding system that means no coding system should be used.")
45 47
46 (defun mule-detect-coding-version (st nd) 48 (defun mule-detect-coding-version (st nd)
47 (case mule-sysdep-version 49 (case mule-sysdep-version
48 (2.3 (code-detect-region (point-min) (point-max))) 50 (2.3 (code-detect-region (point-min) (point-max)))
49 (2.4 (detect-coding-region (point-min) (point-max))) 51 ((2.4 3.0 xemacs)
50 (xemacs (detect-coding-region (point-min) (point-max))) 52 (detect-coding-region (point-min) (point-max)))
51 (otherwise nil))) 53 (otherwise nil)))
52 54
53 (defun mule-code-convert-region (st nd code) 55 (defun mule-code-convert-region (st nd code)
54 (if (and (listp code) (car code)) 56 (if (and (listp code) (car code))
55 (setq code (car code))) 57 (setq code (car code)))
56 (case mule-sysdep-version 58 (case mule-sysdep-version
57 (2.3 59 (2.3
58 (setq mc-flag t) 60 (set 'mc-flag t)
59 (code-convert-region (point-min) (point-max) code *internal*) 61 (code-convert-region (point-min) (point-max) code *internal*)
60 (set-file-coding-system code)) 62 (set-file-coding-system code))
61 (2.4 63 (2.4
62 (setq enable-multibyte-characters t) 64 (setq enable-multibyte-characters t)
63 (if (memq code '(autodetect coding-system-automatic)) 65 (if (memq code '(autodetect coding-system-automatic))
64 nil 66 nil
67 (decode-coding-region st nd code)
68 (set-buffer-file-coding-system code)))
69 (3.0
70 (setq enable-multibyte-characters t)
71 (if (memq code '(autodetect automatic-conversion))
72 nil
73 (or code (setq code 'automatic-conversion))
65 (decode-coding-region st nd code) 74 (decode-coding-region st nd code)
66 (set-buffer-file-coding-system code))) 75 (set-buffer-file-coding-system code)))
67 (xemacs 76 (xemacs
68 (if (and (listp code) (not (car code))) 77 (if (and (listp code) (not (car code)))
69 (setq code 'autodetect)) 78 (setq code 'autodetect))
77 (save-excursion 86 (save-excursion
78 (set-buffer (process-buffer proc)) 87 (set-buffer (process-buffer proc))
79 (set 'mc-flag nil) 88 (set 'mc-flag nil)
80 (set 'enable-multibyte-characters nil))) 89 (set 'enable-multibyte-characters nil)))
81 (case mule-sysdep-version 90 (case mule-sysdep-version
82 ((2.4 2.3) 91 ((3.0 2.4 2.3)
83 (set-process-coding-system proc mule-no-coding-system 92 (set-process-coding-system proc mule-no-coding-system
84 mule-no-coding-system)) 93 mule-no-coding-system))
85 (xemacs 94 (xemacs
86 (set-process-input-coding-system proc mule-no-coding-system) 95 (set-process-input-coding-system proc mule-no-coding-system)
87 (set-process-input-coding-system proc mule-no-coding-system)))) 96 (set-process-input-coding-system proc mule-no-coding-system))))
99 108
100 (defun mule-encode-string (str) 109 (defun mule-encode-string (str)
101 (case mule-sysdep-version 110 (case mule-sysdep-version
102 (2.3 111 (2.3
103 (code-convert-string str *internal* mule-retrieval-coding-system)) 112 (code-convert-string str *internal* mule-retrieval-coding-system))
104 ((2.4 xemacs) 113 ((2.4 3.0 xemacs)
105 (encode-coding-string str mule-retrieval-coding-system)) 114 (encode-coding-string str mule-retrieval-coding-system))
106 (otherwise 115 (otherwise
107 str))) 116 str)))
108 117
109 (defun mule-decode-string (str) 118 (defun mule-decode-string (str)
110 (and str 119 (and str
111 (case mule-sysdep-version 120 (case mule-sysdep-version
112 ((2.4 xemacs) 121 ((2.4 3.0 xemacs)
113 (decode-coding-string str mule-retrieval-coding-system)) 122 (decode-coding-string str mule-retrieval-coding-system))
114 (2.3 123 (2.3
115 (code-convert-string str *internal* mule-retrieval-coding-system)) 124 (code-convert-string str *internal* mule-retrieval-coding-system))
116 (otherwise 125 (otherwise
117 str)))) 126 str))))
119 (defun mule-truncate-string (str len &optional pad) 128 (defun mule-truncate-string (str len &optional pad)
120 "Truncate string STR so that string-width of STR is not greater than LEN. 129 "Truncate string STR so that string-width of STR is not greater than LEN.
121 If width of the truncated string is less than LEN, and if a character PAD is 130 If width of the truncated string is less than LEN, and if a character PAD is
122 defined, add padding end of it." 131 defined, add padding end of it."
123 (case mule-sysdep-version 132 (case mule-sysdep-version
124 (2.4 133 ((2.4 3.0)
125 (let ((cl (string-to-vector str)) (n 0) (sw 0)) 134 (let ((cl (string-to-vector str)) (n 0) (sw 0))
126 (if (<= (string-width str) len) str 135 (if (<= (string-width str) len) str
127 (while (<= (setq sw (+ (char-width (aref cl n)) sw)) len) 136 (while (<= (setq sw (+ (char-width (aref cl n)) sw)) len)
128 (setq n (1+ n))) 137 (setq n (1+ n)))
129 (string-match (make-string n ?.) str) 138 (string-match (make-string n ?.) str)
147 (if (<= char 127) 156 (if (<= char 127)
148 char 157 char
149 (case mule-sysdep-version 158 (case mule-sysdep-version
150 (2.3 (make-character lc-ltn1 char)) 159 (2.3 (make-character lc-ltn1 char))
151 (2.4 (make-char charset-latin-iso8859-1 char)) 160 (2.4 (make-char charset-latin-iso8859-1 char))
161 (3.0 (make-char 'latin-iso8859-1 char))
152 (xemacs char) 162 (xemacs char)
153 (otherwise char)))) 163 (otherwise char))))
154 164
155 (case mule-sysdep-version 165 (case mule-sysdep-version
156 ((2.3 2.4 xemacs) nil) 166 ((2.3 2.4 3.0 xemacs) nil)
157 (otherwise (fset 'string-width 'length))) 167 (otherwise (fset 'string-width 'length)))
158 168
159 (and 169 (and
160 (boundp 'MULE) 170 (boundp 'MULE)
161 (not (featurep 'mule)) 171 (not (featurep 'mule))