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"\e(I<^\e(B") (?\e$B$:\e(B ?\e$B%:\e(B "\e(I=^\e(B") (?\e$B$<\e(B ?\e$B%<\e(B "\e(I>^\e(B") (?\e$B$>\e(B ?\e$B%>\e(B "\e(I?^\e(B")
(?\e$B$!\e(B ?\e$B%!\e(B ?\e(I'\e(B) (?\e$B$#\e(B ?\e$B%#\e(B ?\e(I(\e(B) (?\e$B$%\e(B ?\e$B%%\e(B ?\e(I)\e(B) (?\e$B$'\e(B ?\e$B%'\e(B ?\e(I*\e(B) (?\e$B$)\e(B ?\e$B%)\e(B ?\e(I+\e(B)
(?\e$B$C\e(B ?\e$B%C\e(B ?\e(I/\e(B)
(?\e$B$c\e(B ?\e$B%c\e(B ?\e(I,\e(B) (?\e$B$e\e(B ?\e$B%e\e(B ?\e(I-\e(B) (?\e$B$g\e(B ?\e$B%g\e(B ?\e(I.\e(B)
- (?\e$B$n\e(B ?\e$B%n\e(B nil)
- (nil ?\e$B%t\e(B "\e(I3^\e(B") (nil ?\e$B%u\e(B nil) (nil ?\e$B%v\e(B nil))
+ (?\e$B$n\e(B ?\e$B%n\e(B "\e(I\\e(B")
+ ("\e$B$&!+\e(B" ?\e$B%t\e(B "\e(I3^\e(B") (nil ?\e$B%u\e(B "\e(I6\e(B") (nil ?\e$B%v\e(B "\e(I9\e(B"))
"Japanese JISX0208 Kana character table.
Each element is of the form (HIRAGANA KATAKANA HANKAKU-KATAKANA), where
HIRAGANA and KATAKANA belong to `japanese-jisx0208',
hiragana (car slot) katakana (nth 1 slot) jisx0201 (nth 2 slot)
l (cdr l))
(if hiragana
- (progn
+ (if (stringp hiragana)
+ (if (> (length hiragana) 1)
+ (let ((hira (aref hiragana 0)))
+ (put-char-code-property
+ hira 'composition
+ (cons (cons (aref hiragana 1) katakana)
+ (get-char-code-property hira 'composition)))))
(put-char-code-property hiragana 'katakana katakana)
- (put-char-code-property katakana 'hiragana hiragana)
- (if jisx0201
- (progn
- (put-char-code-property hiragana 'jisx0201 jisx0201)
- (if (integerp jisx0201)
- (put-char-code-property jisx0201 'hiragana hiragana))))))
+ (put-char-code-property hiragana 'jisx0201 jisx0201)))
+ (when (integerp katakana)
+ (put-char-code-property katakana 'hiragana hiragana)
+ (put-char-code-property katakana 'jisx0201 jisx0201))
(if jisx0201
- (progn
- (put-char-code-property katakana 'jisx0201 jisx0201)
- (if (integerp jisx0201)
- (put-char-code-property jisx0201 'katakana katakana))))))
+ (if (stringp jisx0201)
+ (if (> (length jisx0201) 1)
+ (let ((kana (aref jisx0201 0)))
+ (put-char-code-property
+ kana 'composition
+ (cons (cons (aref jisx0201 1) katakana)
+ (get-char-code-property kana 'composition)))))
+ (put-char-code-property jisx0201 'hiragana hiragana)
+ (put-char-code-property jisx0201 'katakana katakana)
+ (put-char-code-property jisx0201 'jisx0208 katakana)))))
(defconst japanese-symbol-table
- '((?\\e$B!!\e(B ?\ ) (?\e$B!"\e(B ?, ?\e(I$\e(B) (?\e$B!#\e(B ?. ?\e(I!\e(B) (?\e$B!$\e(B ?, ?\e(I$\e(B) (?\e$B!%\e(B ?. ?\e(I!\e(B) (?\e$B!&\e(B nil ?\e(I%\e(B)
+ '((?\\e$B!!\e(B ?\ ) (?\e$B!$\e(B ?, ?\e(I$\e(B) (?\e$B!%\e(B ?. ?\e(I!\e(B) (?\e$B!"\e(B ?, ?\e(I$\e(B) (?\e$B!#\e(B ?. ?\e(I!\e(B) (?\e$B!&\e(B nil ?\e(I%\e(B)
(?\e$B!'\e(B ?:) (?\e$B!(\e(B ?\;) (?\e$B!)\e(B ??) (?\e$B!*\e(B ?!) (?\e$B!+\e(B nil ?\e(I^\e(B) (?\e$B!,\e(B nil ?\e(I_\e(B)
(?\e$B!-\e(B ?') (?\e$B!.\e(B ?`) (?\e$B!0\e(B ?^) (?\e$B!2\e(B ?_) (?\e$B!<\e(B ?-) (?\e$B!=\e(B ?-) (?\e$B!>\e(B ?-)
(?\e$B!?\e(B ?/) (?\e$B!@\e(B ?\\) (?\e$B!A\e(B ?~) (?\e$B!C\e(B ?|) (?\e$B!F\e(B ?`) (?\e$B!G\e(B ?') (?\e$B!H\e(B ?\") (?\e$B!I\e(B ?\")
(narrow-to-region from to)
(goto-char (point-min))
(while (re-search-forward "\\cH\\|\\cK" nil t)
- (let* ((hira (preceding-char))
- (kata (japanese-katakana hira hankaku)))
- (if kata
+ (let* ((kana (preceding-char))
+ (composition (get-char-code-property kana 'composition))
+ next slot)
+ (if (and composition (setq slot (assq (following-char) composition)))
(progn
- (delete-region (match-beginning 0) (match-end 0))
- (insert kata)))))))
+ (delete-region (match-beginning 0) (1+ (point)))
+ (insert (cdr slot)))
+ (let ((kata (get-char-code-property
+ kana (if hankaku 'jisx0201 'katakana))))
+ (if kata
+ (progn
+ (delete-region (match-beginning 0) (match-end 0))
+ (insert kata)))))))))
;;;###autoload
(defun japanese-hiragana-region (from to)
- "Convert Japanese `katakana' chars in the region to `hiragana' chars."
+ "Convert Japanese `katakana' chars in the region to `hiragana' chars."
(interactive "r")
(save-restriction
(narrow-to-region from to)
(goto-char (point-min))
(while (re-search-forward "\\cK\\|\\ck" nil t)
(let* ((kata (preceding-char))
- (hira (japanese-hiragana kata)))
- (if hira
+ (composition (get-char-code-property kata 'composition))
+ next slot)
+ (if (and composition (setq slot (assq (following-char) composition)))
(progn
- (delete-region (match-beginning 0) (match-end 0))
- (insert hira)))))))
+ (delete-region (match-beginning 0) (1+ (point)))
+ (insert (get-char-code-property (cdr slot) 'hiragana)))
+ (let ((hira (get-char-code-property kata 'hiragana)))
+ (if hira
+ (progn
+ (delete-region (match-beginning 0) (match-end 0))
+ (insert hira)))))))))
;;;###autoload
(defun japanese-hankaku-region (from to &optional ascii-only)
(goto-char (point-min))
(while (re-search-forward "\\cj" nil t)
(let* ((zenkaku (preceding-char))
- (hankaku (japanese-hankaku zenkaku ascii-only)))
+ (hankaku (or (get-char-code-property zenkaku 'ascii)
+ (and (not ascii-only)
+ (get-char-code-property zenkaku 'jisx0201)))))
(if hankaku
(progn
(delete-region (match-beginning 0) (match-end 0))
(goto-char (point-min))
(while (re-search-forward "\\ca\\|\\ck" nil t)
(let* ((hankaku (preceding-char))
- (zenkaku (japanese-zenkaku hankaku)))
- (if zenkaku
+ (composition (get-char-code-property hankaku 'composition))
+ next slot)
+ (if (and composition (setq slot (assq (following-char) composition)))
(progn
- (delete-region (match-beginning 0) (match-end 0))
- (insert zenkaku)))))))
+ (delete-region (match-beginning 0) (1+ (point)))
+ (insert (cdr slot)))
+ (let ((zenkaku (japanese-zenkaku hankaku)))
+ (if zenkaku
+ (progn
+ (delete-region (match-beginning 0) (match-end 0))
+ (insert zenkaku)))))))))
;;;###autoload
(defun read-hiragana-string (prompt &optional initial-input)