Mercurial > emacs
annotate lisp/language/japan-util.el @ 18542:9503ed5384c5
Change category 5 to 1.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 02 Jul 1997 12:58:22 +0000 |
parents | 1cf4e09c841d |
children | 5b263fdf71a2 |
rev | line source |
---|---|
17315
a3ca5e15c82a
Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1 ;;; japan-util.el --- utilities for Japanese |
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, Japanese | |
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-japanese-environment () |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
29 "Setup multilingual environment (MULE) for Japanese." |
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) |
18203
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
32 (setq coding-category-iso-8-2 'japanese-iso-8bit) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
33 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
34 (set-coding-priority |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
35 '(coding-category-iso-7 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
36 coding-category-iso-8-2 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
37 coding-category-sjis |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
38 coding-category-iso-8-1 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
39 coding-category-iso-else |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
40 coding-category-emacs-mule)) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
41 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
42 (if (eq system-type 'ms-dos) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
43 (progn |
18203
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
44 (setq-default buffer-file-coding-system 'japanese-shift-jis) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
45 (set-terminal-coding-system-internal 'japanese-shift-jis) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
46 (set-keyboard-coding-system-internal 'japanese-shift-jis) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
47 (setq default-process-coding-system |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
48 '(japanese-shift-jis-dos . japanese-shift-jis-dos))) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
49 (setq-default buffer-file-coding-system 'iso-2022-7bit) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
50 (set-terminal-coding-system-internal 'iso-2022-7bit) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
51 (set-keyboard-coding-system-internal 'iso-2022-7bit)) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
52 |
18203
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
53 (setq default-input-method '("Japanese" . "quail-ja")) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
54 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
55 (setq sendmail-coding-system 'iso-2022-jp |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
56 rmail-file-coding-system 'iso-2022-jp) |
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 |
17052 | 59 (defconst japanese-kana-table |
60 '((?$B$"(B ?$B%"(B ?(I1(B) (?$B$$(B ?$B%$(B ?(I2(B) (?$B$&(B ?$B%&(B ?(I3(B) (?$B$((B ?$B%((B ?(I4(B) (?$B$*(B ?$B%*(B ?(I5(B) | |
61 (?$B$+(B ?$B%+(B ?(I6(B) (?$B$-(B ?$B%-(B ?(I7(B) (?$B$/(B ?$B%/(B ?(I8(B) (?$B$1(B ?$B%1(B ?(I9(B) (?$B$3(B ?$B%3(B ?(I:(B) | |
62 (?$B$5(B ?$B%5(B ?(I;(B) (?$B$7(B ?$B%7(B ?(I<(B) (?$B$9(B ?$B%9(B ?(I=(B) (?$B$;(B ?$B%;(B ?(I>(B) (?$B$=(B ?$B%=(B ?(I?(B) | |
63 (?$B$?(B ?$B%?(B ?(I@(B) (?$B$A(B ?$B%A(B ?(IA(B) (?$B$D(B ?$B%D(B ?(IB(B) (?$B$F(B ?$B%F(B ?(IC(B) (?$B$H(B ?$B%H(B ?(ID(B) | |
64 (?$B$J(B ?$B%J(B ?(IE(B) (?$B$K(B ?$B%K(B ?(IF(B) (?$B$L(B ?$B%L(B ?(IG(B) (?$B$M(B ?$B%M(B ?(IH(B) (?$B$N(B ?$B%N(B ?(II(B) | |
65 (?$B$O(B ?$B%O(B ?(IJ(B) (?$B$R(B ?$B%R(B ?(IK(B) (?$B$U(B ?$B%U(B ?(IL(B) (?$B$X(B ?$B%X(B ?(IM(B) (?$B$[(B ?$B%[(B ?(IN(B) | |
66 (?$B$^(B ?$B%^(B ?(IO(B) (?$B$_(B ?$B%_(B ?(IP(B) (?$B$`(B ?$B%`(B ?(IQ(B) (?$B$a(B ?$B%a(B ?(IR(B) (?$B$b(B ?$B%b(B ?(IS(B) | |
67 (?$B$d(B ?$B%d(B ?(IT(B) (?$B$f(B ?$B%f(B ?(IU(B) (?$B$h(B ?$B%h(B ?(IV(B) | |
68 (?$B$i(B ?$B%i(B ?(IW(B) (?$B$j(B ?$B%j(B ?(IX(B) (?$B$k(B ?$B%k(B ?(IY(B) (?$B$l(B ?$B%l(B ?(IZ(B) (?$B$m(B ?$B%m(B ?(I[(B) | |
69 (?$B$o(B ?$B%o(B ?(I\(B) (?$B$p(B ?$B%p(B nil) (?$B$q(B ?$B%q(B nil) (?$B$r(B ?$B%r(B ?(I&(B) | |
70 (?$B$s(B ?$B%s(B ?(I](B) | |
71 (?$B$,(B ?$B%,(B "(I6^(B") (?$B$.(B ?$B%.(B "(I7^(B") (?$B$0(B ?$B%0(B "(I8^(B") (?$B$2(B ?$B%2(B "(I9^(B") (?$B$4(B ?$B%4(B "(I:^(B") | |
72 (?$B$6(B ?$B%6(B "(I;^(B") (?$B$8(B ?$B%8(B "(I<^(B") (?$B$:(B ?$B%:(B "(I=^(B") (?$B$<(B ?$B%<(B "(I>^(B") (?$B$>(B ?$B%>(B "(I?^(B") | |
73 (?$B$@(B ?$B%@(B "(I@^(B") (?$B$B(B ?$B%B(B "(IA^(B") (?$B$E(B ?$B%E(B "(IB^(B") (?$B$G(B ?$B%G(B "(IC^(B") (?$B$I(B ?$B%I(B "(ID^(B") | |
74 (?$B$P(B ?$B%P(B "(IJ^(B") (?$B$S(B ?$B%S(B "(IK^(B") (?$B$V(B ?$B%V(B "(IL^(B") (?$B$Y(B ?$B%Y(B "(IM^(B") (?$B$\(B ?$B%\(B "(IN^(B") | |
75 (?$B$Q(B ?$B%Q(B "(IJ_(B") (?$B$T(B ?$B%T(B "(IK_(B") (?$B$W(B ?$B%W(B "(IL_(B") (?$B$Z(B ?$B%Z(B "(IM_(B") (?$B$](B ?$B%](B "(IN_(B") | |
76 (?$B$!(B ?$B%!(B ?(I'(B) (?$B$#(B ?$B%#(B ?(I((B) (?$B$%(B ?$B%%(B ?(I)(B) (?$B$'(B ?$B%'(B ?(I*(B) (?$B$)(B ?$B%)(B ?(I+(B) | |
77 (?$B$C(B ?$B%C(B ?(I/(B) | |
78 (?$B$c(B ?$B%c(B ?(I,(B) (?$B$e(B ?$B%e(B ?(I-(B) (?$B$g(B ?$B%g(B ?(I.(B) | |
79 (?$B$n(B ?$B%n(B nil) | |
80 (nil ?$B%t(B "(I3^(B") (nil ?$B%u(B nil) (nil ?$B%v(B nil)) | |
81 "Japanese JISX0208 Kana character table. | |
82 Each element is of the form (HIRAGANA KATAKANA HANKAKU-KATAKANA), where | |
83 HIRAGANA and KATAKANA belong to `japanese-jisx0208', | |
84 HANKAKU-KATAKANA belongs to `japanese-jisx0201-kana'.") | |
85 | |
86 ;; Put properties 'katakana, 'hiragana, and 'jix0201 to each Japanese | |
87 ;; kana characters for conversion among them. | |
88 (let ((l japanese-kana-table) | |
89 slot hiragana katakana jisx0201) | |
90 (while l | |
91 (setq slot (car l) | |
92 hiragana (car slot) katakana (nth 1 slot) jisx0201 (nth 2 slot) | |
93 l (cdr l)) | |
94 (if hiragana | |
95 (progn | |
96 (put-char-code-property hiragana 'katakana katakana) | |
97 (put-char-code-property katakana 'hiragana hiragana) | |
98 (if jisx0201 | |
99 (progn | |
100 (put-char-code-property hiragana 'jisx0201 jisx0201) | |
101 (if (integerp jisx0201) | |
102 (put-char-code-property jisx0201 'hiragana hiragana)))))) | |
103 (if jisx0201 | |
104 (progn | |
105 (put-char-code-property katakana 'jisx0201 jisx0201) | |
106 (if (integerp jisx0201) | |
107 (put-char-code-property jisx0201 'katakana katakana)))))) | |
108 | |
109 (defconst japanese-symbol-table | |
110 '((?\$B!!(B ?\ ) (?$B!"(B ?, ?(I$(B) (?$B!#(B ?. ?(I!(B) (?$B!$(B ?, ?(I$(B) (?$B!%(B ?. ?(I!(B) (?$B!&(B nil ?(I%(B) | |
111 (?$B!'(B ?:) (?$B!((B ?\;) (?$B!)(B ??) (?$B!*(B ?!) (?$B!+(B nil ?(I^(B) (?$B!,(B nil ?(I_(B) | |
112 (?$B!-(B ?') (?$B!.(B ?`) (?$B!0(B ?^) (?$B!2(B ?_) (?$B!<(B ?-) (?$B!=(B ?-) (?$B!>(B ?-) | |
113 (?$B!?(B ?/) (?$B!@(B ?\\) (?$B!A(B ?~) (?$B!C(B ?|) (?$B!F(B ?`) (?$B!G(B ?') (?$B!H(B ?\") (?$B!I(B ?\") | |
114 (?\$B!J(B ?\() (?\$B!K(B ?\)) (?\$B!N(B ?[) (?\$B!O(B ?]) (?\$B!P(B ?{) (?\$B!Q(B ?}) | |
115 (?$B!R(B ?<) (?$B!S(B ?>) (?$B!\(B ?+) (?$B!](B ?-) (?$B!a(B ?=) (?$B!c(B ?<) (?$B!d(B ?>) | |
116 (?$B!l(B ?') (?$B!m(B ?\") (?$B!o(B ?\\) (?$B!p(B ?$) (?$B!s(B ?%) (?$B!t(B ?#) (?$B!u(B ?&) (?$B!v(B ?*) | |
117 (?$B!w(B ?@)) | |
118 "Japanese JISX0208 symbol character table. | |
119 Each element is of the form (SYMBOL ASCII HANKAKU), where SYMBOL | |
120 belongs to `japanese-jisx0208', ASCII belongs to `ascii', and HANKAKU | |
121 belongs to `japanese-jisx0201-kana'.") | |
122 | |
123 ;; Put properties 'jisx0208, 'jisx0201, and 'ascii to each Japanese | |
124 ;; symbol and ASCII characters for conversion among them. | |
125 (let ((l japanese-symbol-table) | |
126 slot jisx0208 ascii jisx0201) | |
127 (while l | |
128 (setq slot (car l) | |
129 jisx0208 (car slot) ascii (nth 1 slot) jisx0201 (nth 2 slot) | |
130 l (cdr l)) | |
131 (if ascii | |
132 (progn | |
133 (put-char-code-property jisx0208 'ascii ascii) | |
134 (put-char-code-property ascii 'jisx0208 jisx0208))) | |
135 (if jisx0201 | |
136 (progn | |
137 (put-char-code-property jisx0208 'jisx0201 jisx0201) | |
138 (put-char-code-property jisx0201 'jisx0208 jisx0208))))) | |
139 | |
140 (defconst japanese-alpha-numeric-table | |
141 '((?$B#0(B . ?0) (?$B#1(B . ?1) (?$B#2(B . ?2) (?$B#3(B . ?3) (?$B#4(B . ?4) | |
142 (?$B#5(B . ?5) (?$B#6(B . ?6) (?$B#7(B . ?7) (?$B#8(B . ?8) (?$B#9(B . ?9) | |
143 (?$B#A(B . ?A) (?$B#B(B . ?B) (?$B#C(B . ?C) (?$B#D(B . ?D) (?$B#E(B . ?E) | |
144 (?$B#F(B . ?F) (?$B#G(B . ?G) (?$B#H(B . ?H) (?$B#I(B . ?I) (?$B#J(B . ?J) | |
145 (?$B#K(B . ?K) (?$B#L(B . ?L) (?$B#M(B . ?M) (?$B#N(B . ?N) (?$B#O(B . ?O) | |
146 (?$B#P(B . ?P) (?$B#Q(B . ?Q) (?$B#R(B . ?R) (?$B#S(B . ?S) (?$B#T(B . ?T) | |
147 (?$B#U(B . ?U) (?$B#V(B . ?V) (?$B#W(B . ?W) (?$B#X(B . ?X) (?$B#Y(B . ?Y) (?$B#Z(B . ?Z) | |
148 (?$B#a(B . ?a) (?$B#b(B . ?b) (?$B#c(B . ?c) (?$B#d(B . ?d) (?$B#e(B . ?e) | |
149 (?$B#f(B . ?f) (?$B#g(B . ?g) (?$B#h(B . ?h) (?$B#i(B . ?i) (?$B#j(B . ?j) | |
150 (?$B#k(B . ?k) (?$B#l(B . ?l) (?$B#m(B . ?m) (?$B#n(B . ?n) (?$B#o(B . ?o) | |
151 (?$B#p(B . ?p) (?$B#q(B . ?q) (?$B#r(B . ?r) (?$B#s(B . ?s) (?$B#t(B . ?t) | |
152 (?$B#u(B . ?u) (?$B#v(B . ?v) (?$B#w(B . ?w) (?$B#x(B . ?x) (?$B#y(B . ?y) (?$B#z(B . ?z)) | |
153 "Japanese JISX0208 alpha numeric character table. | |
154 Each element is of the form (ALPHA-NUMERIC ASCII), where ALPHA-NUMERIC | |
155 belongs to `japanese-jisx0208', ASCII belongs to `ascii'.") | |
156 | |
157 ;; Put properties 'jisx0208 and 'ascii to each Japanese alpha numeric | |
158 ;; and ASCII characters for conversion between them. | |
159 (let ((l japanese-alpha-numeric-table) | |
160 slot jisx0208 ascii) | |
161 (while l | |
162 (setq slot (car l) | |
163 jisx0208 (car slot) ascii (cdr slot) | |
164 l (cdr l)) | |
165 (put-char-code-property jisx0208 'ascii ascii) | |
166 (put-char-code-property ascii 'jisx0208 jisx0208))) | |
167 | |
168 ;; Convert string STR by FUNC and return a resulting string. | |
169 (defun japanese-string-conversion (str func &rest args) | |
170 (let ((buf (get-buffer-create " *Japanese work*"))) | |
171 (save-excursion | |
172 (set-buffer buf) | |
173 (erase-buffer) | |
174 (insert str) | |
175 (apply func 1 (point) args) | |
176 (buffer-string)))) | |
177 | |
178 ;;;###autoload | |
179 (defun japanese-katakana (obj &optional hankaku) | |
180 "Convert argument to Katakana and return that. | |
181 The argument may be a character or string. The result has the same type. | |
182 The argument object is not altered--the value is a copy. | |
183 Optional argument HANKAKU t means to convert to `hankaku' Katakana | |
184 \(`japanese-jisx0201-kana'), in which case return value | |
185 may be a string even if OBJ is a character if two Katakanas are | |
186 necessary to represent OBJ." | |
187 (if (stringp obj) | |
188 (japanese-string-conversion obj 'japanese-katakana-region hankaku) | |
189 (or (get-char-code-property obj (if hankaku 'jisx0201 'katakana)) | |
190 obj))) | |
191 | |
192 ;;;###autoload | |
193 (defun japanese-hiragana (obj) | |
194 "Convert argument to Hiragana and return that. | |
195 The argument may be a character or string. The result has the same type. | |
196 The argument object is not altered--the value is a copy." | |
197 (if (stringp obj) | |
198 (japanese-string-conversion obj 'japanese-hiragana-region) | |
199 (or (get-char-code-property obj 'hiragana) | |
200 obj))) | |
201 | |
202 ;;;###autoload | |
203 (defun japanese-hankaku (obj &optional ascii-only) | |
204 "Convert argument to `hankaku' and return that. | |
205 The argument may be a character or string. The result has the same type. | |
206 The argument object is not altered--the value is a copy. | |
207 Optional argument ASCII-ONLY non-nil means to return only ASCII character." | |
208 (if (stringp obj) | |
209 (japanese-string-conversion obj 'japanese-hankaku-region ascii-only) | |
210 (or (get-char-code-property obj 'ascii) | |
211 (and (not ascii-only) | |
212 (get-char-code-property obj 'jisx0201)) | |
213 obj))) | |
214 | |
215 ;;;###autoload | |
216 (defun japanese-zenkaku (obj) | |
217 "Convert argument to `zenkaku' and return that. | |
218 The argument may be a character or string. The result has the same type. | |
219 The argument object is not altered--the value is a copy." | |
220 (if (stringp obj) | |
221 (japanese-string-conversion obj 'japanese-zenkaku-region) | |
222 (or (get-char-code-property obj 'jisx0208) | |
223 obj))) | |
224 | |
225 ;;;###autoload | |
226 (defun japanese-katakana-region (from to &optional hankaku) | |
227 "Convert Japanese `hiragana' chars in the region to `katakana' chars. | |
228 Optional argument HANKAKU t means to convert to `hankaku katakana' character | |
229 of which charset is `japanese-jisx0201-kana'." | |
230 (interactive "r\nP") | |
231 (save-restriction | |
232 (narrow-to-region from to) | |
233 (goto-char (point-min)) | |
234 (while (re-search-forward "\\cH\\|\\cK" nil t) | |
235 (let* ((hira (preceding-char)) | |
236 (kata (japanese-katakana hira hankaku))) | |
237 (if kata | |
238 (progn | |
239 (delete-region (match-beginning 0) (match-end 0)) | |
240 (insert kata))))))) | |
241 | |
242 ;;;###autoload | |
243 (defun japanese-hiragana-region (from to) | |
244 "Convert Japanese `katakana' chars in the region to `hiragana' chars." | |
245 (interactive "r") | |
246 (save-restriction | |
247 (narrow-to-region from to) | |
248 (goto-char (point-min)) | |
249 (while (re-search-forward "\\cK\\|\\ck" nil t) | |
250 (let* ((kata (preceding-char)) | |
251 (hira (japanese-hiragana kata))) | |
252 (if hira | |
253 (progn | |
254 (delete-region (match-beginning 0) (match-end 0)) | |
255 (insert hira))))))) | |
256 | |
257 ;;;###autoload | |
258 (defun japanese-hankaku-region (from to &optional ascii-only) | |
259 "Convert Japanese `zenkaku' chars in the region to `hankaku' chars. | |
260 `Zenkaku' chars belong to `japanese-jisx0208' | |
261 `Hankaku' chars belong to `ascii' or `japanese-jisx0201-kana'. | |
262 Optional argument ASCII-ONLY non-nil means to convert only to ASCII char." | |
263 (interactive "r\nP") | |
264 (save-restriction | |
265 (narrow-to-region from to) | |
266 (goto-char (point-min)) | |
267 (while (re-search-forward "\\cj" nil t) | |
268 (let* ((zenkaku (preceding-char)) | |
269 (hankaku (japanese-hankaku zenkaku ascii-only))) | |
270 (if hankaku | |
271 (progn | |
272 (delete-region (match-beginning 0) (match-end 0)) | |
273 (insert hankaku))))))) | |
274 | |
275 ;;;###autoload | |
276 (defun japanese-zenkaku-region (from to) | |
277 "Convert hankaku' chars in the region to Japanese `zenkaku' chars. | |
278 `Zenkaku' chars belong to `japanese-jisx0208' | |
279 `Hankaku' chars belong to `ascii' or `japanese-jisx0201-kana'." | |
280 (interactive "r") | |
281 (save-restriction | |
282 (narrow-to-region from to) | |
283 (goto-char (point-min)) | |
284 (while (re-search-forward "\\ca\\|\\ck" nil t) | |
285 (let* ((hankaku (preceding-char)) | |
286 (zenkaku (japanese-zenkaku hankaku))) | |
287 (if zenkaku | |
288 (progn | |
289 (delete-region (match-beginning 0) (match-end 0)) | |
290 (insert zenkaku))))))) | |
291 | |
292 ;;;###autoload | |
293 (defun read-hiragana-string (prompt &optional initial-input) | |
294 "Read a Hiragana string from the minibuffer, prompting with string PROMPT. | |
295 If non-nil, second arg INITIAL-INPUT is a string to insert before reading." | |
18415
1cf4e09c841d
(read-hiragana-string): Call read-multilingual-string correctly.
Richard M. Stallman <rms@gnu.org>
parents:
18377
diff
changeset
|
296 (read-multilingual-string prompt initial-input "quail-ja-hiragana")) |
17052 | 297 |
298 ;; | |
18309
bd8b521f5218
Provide XXX-util instead of
Kenichi Handa <handa@m17n.org>
parents:
18203
diff
changeset
|
299 (provide 'japan-util) |
17052 | 300 |
301 ;;; japan-util.el ends here |