Mercurial > emacs
annotate lisp/language/china-util.el @ 19140:a86f1b81dcf5
(setup-chinese-gb-environment): Do not
call set-terminal-coding-system and set-keyboard-coding-system,
instead call set-defualt-coding-systems.
(setup-chinese-big5-environment): Likewise.
(setup-chinese-cns-environment): Likewise.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 04 Aug 1997 07:01:31 +0000 |
parents | 6835f9c00ff5 |
children | 0fb8728cd236 |
rev | line source |
---|---|
17315
a3ca5e15c82a
Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents:
17098
diff
changeset
|
1 ;;; china-util.el --- utilities for Chinese |
17052 | 2 |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
18377
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
18309
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
17052 | 5 |
6 ;; Keywords: mule, multilingual, Chinese | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
17071 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
17052 | 24 |
25 ;;; Code: | |
26 | |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
27 ;;;###autoload |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
28 (defun setup-chinese-gb-environment () |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
29 "Setup multilingual environment (MULE) for Chinese GB2312 users." |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
30 (interactive) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
31 (setup-english-environment) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
32 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
33 (setq primary-language "Chinese-GB") |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
34 |
19140
a86f1b81dcf5
(setup-chinese-gb-environment): Do not
Kenichi Handa <handa@m17n.org>
parents:
19092
diff
changeset
|
35 (set-default-coding-systems 'chinese-iso-8bit) |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
36 (setq coding-category-iso-8-2 'chinese-iso-8bit) |
18793
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
37 (setq coding-category-iso-7-else 'chinese-iso-7bit) |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
38 (setq coding-category-big5 'chinese-big5) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
39 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
40 (set-coding-priority |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
41 '(coding-category-iso-7 |
18793
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
42 coding-category-iso-7-else |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
43 coding-category-iso-8-2 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
44 coding-category-big5 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
45 coding-category-iso-8-1 |
18793
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
46 coding-category-emacs-mule |
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
47 coding-category-iso-8-else)) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
48 |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
49 (setq-default buffer-file-coding-system 'chinese-iso-8bit) |
19140
a86f1b81dcf5
(setup-chinese-gb-environment): Do not
Kenichi Handa <handa@m17n.org>
parents:
19092
diff
changeset
|
50 (setq default-terminal-coding-system 'chinese-iso-8bit) |
a86f1b81dcf5
(setup-chinese-gb-environment): Do not
Kenichi Handa <handa@m17n.org>
parents:
19092
diff
changeset
|
51 (setq default-keyboard-coding-system 'chinese-iso-8bit) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
52 (setq sendmail-coding-system nil |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
53 rmail-file-coding-system 'chinese-iso-7bit) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
54 |
19092
6835f9c00ff5
(setup-chinese-gb-environment): Set
Kenichi Handa <handa@m17n.org>
parents:
18793
diff
changeset
|
55 (setq default-input-method "chinese-py-punct") |
6835f9c00ff5
(setup-chinese-gb-environment): Set
Kenichi Handa <handa@m17n.org>
parents:
18793
diff
changeset
|
56 (setq-default default-input-method "chinese-py-punct")) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
57 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
58 ;;;###autoload |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
59 (defun setup-chinese-big5-environment () |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
60 "Setup multilingual environment (MULE) for Chinese Big5 users." |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
61 (interactive) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
62 (setup-english-environment) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
63 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
64 (setq primary-language "Chinese-BIG5") |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
65 |
19140
a86f1b81dcf5
(setup-chinese-gb-environment): Do not
Kenichi Handa <handa@m17n.org>
parents:
19092
diff
changeset
|
66 (set-default-coding-systems 'chinese-big5) |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
67 (setq coding-category-iso-8-2 'chinese-big5) |
18793
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
68 (setq coding-category-iso-7-else 'chinese-iso-7bit) |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
69 (setq coding-category-big5 'chinese-big5) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
70 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
71 (set-coding-priority |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
72 '(coding-category-iso-7 |
18793
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
73 coding-category-iso-7-else |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
74 coding-category-big5 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
75 coding-category-iso-8-2 |
18793
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
76 coding-category-emacs-mule |
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
77 coding-category-iso-8-else)) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
78 |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
79 (setq-default buffer-file-coding-system 'chinese-big5) |
19140
a86f1b81dcf5
(setup-chinese-gb-environment): Do not
Kenichi Handa <handa@m17n.org>
parents:
19092
diff
changeset
|
80 (setq default-terminal-coding-system 'chinese-big5) |
a86f1b81dcf5
(setup-chinese-gb-environment): Do not
Kenichi Handa <handa@m17n.org>
parents:
19092
diff
changeset
|
81 (setq default-keyboard-coding-system 'chinese-big5) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
82 (setq sendmail-coding-system nil |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
83 rmail-file-coding-system 'chienese-iso-7bit) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
84 |
19092
6835f9c00ff5
(setup-chinese-gb-environment): Set
Kenichi Handa <handa@m17n.org>
parents:
18793
diff
changeset
|
85 (setq default-input-method "chinese-py-punct-b5") |
6835f9c00ff5
(setup-chinese-gb-environment): Set
Kenichi Handa <handa@m17n.org>
parents:
18793
diff
changeset
|
86 (setq-default default-input-method "chinese-py-punct-b5")) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
87 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
88 ;;;###autoload |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
89 (defun setup-chinese-cns-environment () |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
90 "Setup multilingual environment (MULE) for Chinese CNS11643 family users." |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
91 (interactive) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
92 (setup-english-environment) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
93 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
94 (setq primary-language "Chinese-CNS") |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
95 |
18793
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
96 (setq coding-category-iso-7-else 'chinese-iso-7bit) |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
97 (setq coding-category-big5 'chinese-big5) |
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
98 (setq coding-category-iso-8-2 'chinese-big5) |
19140
a86f1b81dcf5
(setup-chinese-gb-environment): Do not
Kenichi Handa <handa@m17n.org>
parents:
19092
diff
changeset
|
99 (set-default-coding-systems 'chinese-iso-7bit) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
100 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
101 (set-coding-priority |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
102 '(coding-category-iso-7 |
18793
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
103 coding-category-iso-7-else |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
104 coding-category-iso-8-2 |
18793
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
105 coding-category-big5 |
f98c1cb6b807
(setup-chinese-gb-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18553
diff
changeset
|
106 coding-category-iso-7-else)) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
107 |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
108 (setq-default buffer-file-coding-system 'chinese-iso-7bit) |
19140
a86f1b81dcf5
(setup-chinese-gb-environment): Do not
Kenichi Handa <handa@m17n.org>
parents:
19092
diff
changeset
|
109 (setq default-terminal-coding-system 'chinese-iso-7bit) |
a86f1b81dcf5
(setup-chinese-gb-environment): Do not
Kenichi Handa <handa@m17n.org>
parents:
19092
diff
changeset
|
110 (setq default-keyboard-coding-system 'chinese-iso-7bit) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
111 (setq sendmail-coding-system nil |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
112 rmail-file-coding-system 'chinese-iso-7bit) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
113 |
19092
6835f9c00ff5
(setup-chinese-gb-environment): Set
Kenichi Handa <handa@m17n.org>
parents:
18793
diff
changeset
|
114 (setq default-input-method "chinese-quick-cns") |
6835f9c00ff5
(setup-chinese-gb-environment): Set
Kenichi Handa <handa@m17n.org>
parents:
18793
diff
changeset
|
115 (setq-default default-input-method "chinese-quick-cns")) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
116 |
17052 | 117 ;; Hz/ZW encoding stuffs |
118 | |
119 ;; HZ is an encoding method for Chinese character set GB2312 used | |
120 ;; widely in Internet. It is very similar to 7-bit environment of | |
121 ;; ISO-2022. The difference is that HZ uses the sequence "~{" and | |
122 ;; "~}" for designating GB2312 and ASCII respectively, hence, it | |
123 ;; doesn't uses ESC (0x1B) code. | |
124 | |
125 ;; ZW is another encoding method for Chinese character set GB2312. It | |
126 ;; encodes Chinese characters line by line by starting each line with | |
127 ;; the sequence "zW". It also uses only 7-bit as HZ. | |
128 | |
129 ;; ISO-2022 escape sequence to designate GB2312. | |
130 (defvar iso2022-gb-designation "\e$A") | |
131 ;; HZ escape sequence to designate GB2312. | |
132 (defvar hz-gb-designnation "~{") | |
133 ;; ISO-2022 escape sequence to designate ASCII. | |
134 (defvar iso2022-ascii-designation "\e(B") | |
135 ;; HZ escape sequence to designate ASCII. | |
136 (defvar hz-ascii-designnation "~}") | |
137 ;; Regexp of ZW sequence to start GB2312. | |
138 (defvar zw-start-gb "^zW") | |
139 ;; Regexp for start of GB2312 in an encoding mixture of HZ and ZW. | |
140 (defvar hz/zw-start-gb (concat hz-gb-designnation "\\|" zw-start-gb)) | |
141 | |
142 (defvar decode-hz-line-continuation nil | |
143 "Flag to tell if we should care line continuation convention of Hz.") | |
144 | |
145 ;;;###autoload | |
146 (defun decode-hz-region (beg end) | |
147 "Decode HZ/ZW encoded text in the current region. | |
148 Return the length of resulting text." | |
149 (interactive "r") | |
150 (save-excursion | |
151 (save-restriction | |
152 (narrow-to-region beg end) | |
153 | |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
154 ;; We, at first, convert HZ/ZW to `iso-2022-7bit', |
17052 | 155 ;; then decode it. |
156 | |
157 ;; "~\n" -> "\n" | |
158 (goto-char (point-min)) | |
159 (while (search-forward "~" nil t) | |
160 (if (= (following-char) ?\n) (delete-char -1)) | |
161 (if (not (eobp)) (forward-char 1))) | |
162 | |
163 ;; "^zW...\n" -> Chinese GB2312 | |
164 ;; "~{...~}" -> Chinese GB2312 | |
165 (goto-char (point-min)) | |
166 (let ((chinese-found nil)) | |
167 (while (re-search-forward hz/zw-start-gb nil t) | |
168 (if (= (char-after (match-beginning 0)) ?z) | |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
169 ;; ZW -> iso-2022-7bit |
17052 | 170 (progn |
171 (delete-char -2) | |
172 (insert iso2022-gb-designation) | |
173 (end-of-line) | |
174 (insert iso2022-ascii-designation)) | |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
175 ;; HZ -> iso-2022-7bit |
17052 | 176 (delete-char -2) |
177 (insert iso2022-gb-designation) | |
178 (let ((pos (save-excursion (end-of-line) (point)))) | |
179 (if (search-forward hz-ascii-designnation pos t) | |
180 (replace-match iso2022-ascii-designation) | |
181 (if (not decode-hz-line-continuation) | |
182 (insert iso2022-ascii-designation))))) | |
183 (setq chinese-found t)) | |
184 (if (or chinese-found | |
185 (let ((enable-multibyte-characters nil)) | |
186 ;; Here we check if the text contains EUC (China) codes. | |
187 ;; If any, we had better decode them also. | |
188 (goto-char (point-min)) | |
189 (re-search-forward "[\240-\377]" nil t))) | |
17098
8917133b7e82
Remove prefix "coding-system-" from coding system symbol names.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
190 (decode-coding-region (point-min) (point-max) 'euc-china))) |
17052 | 191 |
192 ;; "~~" -> "~" | |
193 (goto-char (point-min)) | |
194 (while (search-forward "~~" nil t) (delete-char -1)) | |
195 (- (point-max) (point-min))))) | |
196 | |
197 ;;;###autoload | |
198 (defun decode-hz-buffer () | |
199 "Decode HZ/ZW encoded text in the current buffer." | |
200 (interactive) | |
201 (decode-hz-region (point-min) (point-max))) | |
202 | |
203 ;;;###autoload | |
204 (defun encode-hz-region (beg end) | |
205 "Encode the text in the current region to HZ. | |
206 Return the length of resulting text." | |
207 (interactive "r") | |
208 (save-excursion | |
209 (save-restriction | |
210 (narrow-to-region beg end) | |
211 | |
212 ;; "~" -> "~~" | |
213 (goto-char (point-min)) | |
214 (while (search-forward "~" nil t) (insert ?~)) | |
215 | |
216 ;; Chinese GB2312 -> "~{...~}" | |
217 (goto-char (point-min)) | |
218 (if (re-search-forward "\\cc" nil t) | |
219 (let ((enable-multibyte-characters nil) | |
220 pos) | |
221 (goto-char (setq pos (match-beginning 0))) | |
18553
62e17ab4e33e
Use true coding system names instead of
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
222 (encode-coding-region pos (point-max) 'iso-2022-7bit) |
17052 | 223 (goto-char pos) |
224 (while (search-forward iso2022-gb-designation nil t) | |
225 (delete-char -3) | |
226 (insert hz-gb-designnation)) | |
227 (goto-char pos) | |
228 (while (search-forward iso2022-ascii-designation nil t) | |
229 (delete-char -3) | |
230 (insert hz-ascii-designnation)))) | |
231 (- (point-max) (point-min))))) | |
232 | |
233 ;;;###autoload | |
234 (defun encode-hz-buffer () | |
235 "Encode the text in the current buffer to HZ." | |
236 (interactive) | |
237 (encode-hz-region (point-min) (point-max))) | |
238 | |
239 ;; | |
18309
bd8b521f5218
Provide XXX-util instead of
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
240 (provide 'china-util) |
17052 | 241 |
242 ;;; china-util.el ends here |