annotate lisp/language/china-util.el @ 20892:18f3cb26243f before-miles-orphaned-changes gcc-2_8_1-980401 gcc-2_8_1-980407 gcc-2_8_1-980412 gcc-2_8_1-980413 gcc-2_8_1-RELEASE gcc_2_8_1-980315 libc-980214 libc-980215 libc-980216 libc-980217 libc-980218 libc-980219 libc-980220 libc-980221 libc-980222 libc-980223 libc-980224 libc-980225 libc-980226 libc-980227 libc-980228 libc-980301 libc-980302 libc-980303 libc-980304 libc-980306 libc-980307 libc-980308 libc-980309 libc-980310 libc-980311 libc-980312 libc-980313 libc-980314 libc-980315 libc-980316 libc-980317 libc-980318 libc-980319 libc-980320 libc-980321 libc-980322 libc-980323 libc-980324 libc-980325 libc-980326 libc-980327 libc-980328 libc-980329 libc-980330 libc-980331 libc-980401 libc-980402 libc-980403 libc-980404 libc-980405 libc-980406 libc-980407 libc-980408 libc-980409 libc-980410 libc-980411 libc-980412 libc-980413 libc-980414 libc-980428 libc-980429 libc-980430 libc-980501 libc-980502 libc-980503 libc-980504 libc-980505 libc-980506 libc-980507 libc-980508 libc-980509 libc-980510 libc-980512 libc-980513 libc-980514 libc-980515 libc-980516 libc-980517 libc-980518 libc-980519 libc-980520 libc-980521 libc-980522 libc-980523 libc-980524 libc-980525 libc-980526 libc-980527 libc-980528 libc-980529 libc-980530 libc-980531 libc-980601 libc-980602 libc-980603 libc-980604 libc-980605 libc-980606 libc-980607 libc-980608 libc-980609 libc-980610 libc-980611 libc-980612 libc-980613

Add PentiumII (i786). Add '7' to all i[3456] entries. Add AMD and Cyrix names for P5 and P6.
author Richard Kenner <kenner@gnu.org>
date Fri, 13 Feb 1998 12:16:46 +0000
parents 3d67d591c066
children 5e0c74e072de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; Keywords: mule, multilingual, Chinese
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
23 ;; Boston, MA 02111-1307, USA.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;;; Code:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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)
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
32 (set-language-environment-coding-systems "Chinese-GB")
19371
18e804fd153b (setup-chinese-gb-environment): Delete
Kenichi Handa <handa@m17n.org>
parents: 19275
diff changeset
33 (setq default-input-method "chinese-py-punct"))
17993
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
34
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
35 ;;;###autoload
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
36 (defun setup-chinese-big5-environment ()
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
37 "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
38 (interactive)
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
39 (setup-english-environment)
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
40 (set-language-environment-coding-systems "Chinese-BIG5")
19371
18e804fd153b (setup-chinese-gb-environment): Delete
Kenichi Handa <handa@m17n.org>
parents: 19275
diff changeset
41 (setq 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
42
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
43 ;;;###autoload
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
44 (defun setup-chinese-cns-environment ()
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
45 "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
46 (interactive)
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
47 (setup-english-environment)
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
48 (set-language-environment-coding-systems "Chinese-CNS")
19371
18e804fd153b (setup-chinese-gb-environment): Delete
Kenichi Handa <handa@m17n.org>
parents: 19275
diff changeset
49 (setq default-input-method "chinese-quick-cns"))
17993
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
50
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 ;; Hz/ZW encoding stuffs
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 ;; HZ is an encoding method for Chinese character set GB2312 used
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 ;; widely in Internet. It is very similar to 7-bit environment of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 ;; ISO-2022. The difference is that HZ uses the sequence "~{" and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 ;; "~}" for designating GB2312 and ASCII respectively, hence, it
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 ;; doesn't uses ESC (0x1B) code.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 ;; ZW is another encoding method for Chinese character set GB2312. It
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 ;; encodes Chinese characters line by line by starting each line with
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 ;; the sequence "zW". It also uses only 7-bit as HZ.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 ;; ISO-2022 escape sequence to designate GB2312.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 (defvar iso2022-gb-designation "\e$A")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 ;; HZ escape sequence to designate GB2312.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 (defvar hz-gb-designnation "~{")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 ;; ISO-2022 escape sequence to designate ASCII.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 (defvar iso2022-ascii-designation "\e(B")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 ;; HZ escape sequence to designate ASCII.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 (defvar hz-ascii-designnation "~}")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 ;; Regexp of ZW sequence to start GB2312.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 (defvar zw-start-gb "^zW")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 ;; Regexp for start of GB2312 in an encoding mixture of HZ and ZW.
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
74 (defvar hz/zw-start-gb
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
75 (concat hz-gb-designnation "\\|" zw-start-gb "\\|[^\0-\177]"))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 (defvar decode-hz-line-continuation nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 "Flag to tell if we should care line continuation convention of Hz.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
80 (defconst hz-set-msb-table
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
81 (let ((str (make-string 127 0))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
82 (i 0))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
83 (while (< i 33)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
84 (aset str i i)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
85 (setq i (1+ i)))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
86 (while (< i 127)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
87 (aset str i (+ i 128))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
88 (setq i (1+ i)))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
89 str))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
90
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 (defun decode-hz-region (beg end)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 "Decode HZ/ZW encoded text in the current region.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 Return the length of resulting text."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 (interactive "r")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 (save-restriction
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
98 (let (pos ch)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
99 (narrow-to-region beg end)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
101 ;; We, at first, convert HZ/ZW to `euc-china',
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
102 ;; then decode it.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
104 ;; "~\n" -> "\n", "~~" -> "~"
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
105 (goto-char (point-min))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
106 (while (search-forward "~" nil t)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
107 (setq ch (following-char))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
108 (if (or (= ch ?\n) (= ch ?~)) (delete-char -1)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
110 ;; "^zW...\n" -> Chinese GB2312
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
111 ;; "~{...~}" -> Chinese GB2312
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
112 (goto-char (point-min))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
113 (setq beg nil)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 (while (re-search-forward hz/zw-start-gb nil t)
20738
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
115 (setq pos (match-beginning 0)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
116 ch (char-after pos))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
117 ;; Record the first position to start conversion.
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
118 (or beg (setq beg pos))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
119 (end-of-line)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
120 (setq end (point))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
121 (if (>= ch 128) ; 8bit GB2312
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
122 nil
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
123 (goto-char pos)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
124 (delete-char 2)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
125 (setq end (- end 2))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
126 (if (= ch ?z) ; ZW -> euc-china
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
127 (progn
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
128 (translate-region (point) end hz-set-msb-table)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
129 (goto-char end))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
130 (if (search-forward hz-ascii-designnation
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
131 (if decode-hz-line-continuation nil end)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
132 t)
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
133 (delete-char -2))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
134 (setq end (point))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
135 (translate-region pos (point) hz-set-msb-table))))
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
136 (if beg
f510736ce3d1 In setup-LANGUAGE-environment functions,
Kenichi Handa <handa@m17n.org>
parents: 19428
diff changeset
137 (decode-coding-region beg end 'euc-china)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 (- (point-max) (point-min)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 (defun decode-hz-buffer ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 "Decode HZ/ZW encoded text in the current buffer."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 (decode-hz-region (point-min) (point-max)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 (defun encode-hz-region (beg end)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 "Encode the text in the current region to HZ.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 Return the length of resulting text."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 (interactive "r")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 (save-restriction
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 (narrow-to-region beg end)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 ;; "~" -> "~~"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 (goto-char (point-min))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 (while (search-forward "~" nil t) (insert ?~))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 ;; Chinese GB2312 -> "~{...~}"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 (goto-char (point-min))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 (if (re-search-forward "\\cc" nil t)
20838
3d67d591c066 (encode-hz-region): Do not bind
Kenichi Handa <handa@m17n.org>
parents: 20738
diff changeset
162 (let (pos)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 (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
164 (encode-coding-region pos (point-max) 'iso-2022-7bit)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 (goto-char pos)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 (while (search-forward iso2022-gb-designation nil t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 (delete-char -3)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 (insert hz-gb-designnation))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 (goto-char pos)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (while (search-forward iso2022-ascii-designation nil t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 (delete-char -3)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 (insert hz-ascii-designnation))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 (- (point-max) (point-min)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 (defun encode-hz-buffer ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 "Encode the text in the current buffer to HZ."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 (encode-hz-region (point-min) (point-max)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 ;;
18309
bd8b521f5218 Provide XXX-util instead of
Kenichi Handa <handa@m17n.org>
parents: 17993
diff changeset
182 (provide 'china-util)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 ;;; china-util.el ends here