chinese.el 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. ;;; chinese.el --- support for Chinese -*- coding: iso-2022-7bit; -*-
  2. ;; Copyright (C) 2001-2012 Free Software Foundation, Inc.
  3. ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
  4. ;; 2005, 2006, 2007, 2008, 2009, 2010, 2011
  5. ;; National Institute of Advanced Industrial Science and Technology (AIST)
  6. ;; Registration Number H14PRO021
  7. ;; Copyright (C) 2003
  8. ;; National Institute of Advanced Industrial Science and Technology (AIST)
  9. ;; Registration Number H13PRO009
  10. ;; Keywords: multilingual, Chinese
  11. ;; This file is part of GNU Emacs.
  12. ;; GNU Emacs is free software: you can redistribute it and/or modify
  13. ;; it under the terms of the GNU General Public License as published by
  14. ;; the Free Software Foundation, either version 3 of the License, or
  15. ;; (at your option) any later version.
  16. ;; GNU Emacs is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;; GNU General Public License for more details.
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  22. ;;; Commentary:
  23. ;; For Chinese, three character sets GB2312, BIG5, and CNS11643 are
  24. ;; supported.
  25. ;;; Code:
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27. ;;; Chinese (general)
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. (define-coding-system 'iso-2022-cn
  30. "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN)."
  31. :coding-type 'iso-2022
  32. :mnemonic ?C
  33. :charset-list '(ascii chinese-gb2312 chinese-cns11643-1 chinese-cns11643-2)
  34. :designation [ascii
  35. (nil chinese-gb2312 chinese-cns11643-1)
  36. (nil chinese-cns11643-2)
  37. nil]
  38. :flags '(ascii-at-eol ascii-at-cntl 7-bit
  39. designation locking-shift single-shift init-at-bol)
  40. :mime-charset 'iso-2022-cn
  41. :suitable-for-keyboard t)
  42. (define-coding-system-alias 'chinese-iso-7bit 'iso-2022-cn)
  43. (define-coding-system 'iso-2022-cn-ext
  44. "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN-EXT)."
  45. :coding-type 'iso-2022
  46. :mnemonic ?C
  47. :charset-list '(ascii
  48. chinese-gb2312 chinese-cns11643-1
  49. chinese-cns11643-2 chinese-cns11643-3 chinese-cns11643-4
  50. chinese-cns11643-5 chinese-cns11643-6 chinese-cns11643-7)
  51. :designation '[ascii
  52. (nil chinese-gb2312 chinese-cns11643-1)
  53. (nil chinese-cns11643-2)
  54. (nil chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5
  55. chinese-cns11643-6 chinese-cns11643-7)]
  56. :flags '(ascii-at-eol ascii-at-cntl 7-bit
  57. designation locking-shift single-shift init-at-bol)
  58. :mime-charset 'iso-2022-cn-ext
  59. :suitable-for-keyboard t)
  60. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61. ;;; Chinese GB2312 (simplified)
  62. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  63. (define-coding-system 'chinese-iso-8bit
  64. "ISO 2022 based EUC encoding for Chinese GB2312 (MIME:GB2312)."
  65. :coding-type 'iso-2022
  66. :mnemonic ?c
  67. :charset-list '(ascii chinese-gb2312)
  68. :designation [ascii chinese-gb2312 nil nil]
  69. :mime-charset 'gb2312)
  70. (define-coding-system-alias 'cn-gb-2312 'chinese-iso-8bit)
  71. (define-coding-system-alias 'euc-china 'chinese-iso-8bit)
  72. (define-coding-system-alias 'euc-cn 'chinese-iso-8bit)
  73. (define-coding-system-alias 'cn-gb 'chinese-iso-8bit)
  74. (define-coding-system-alias 'gb2312 'chinese-iso-8bit)
  75. (define-coding-system 'chinese-hz
  76. "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)."
  77. :coding-type 'utf-8
  78. :mnemonic ?z
  79. :charset-list '(ascii chinese-gb2312)
  80. :mime-charset 'hz-gb-2312
  81. :post-read-conversion 'post-read-decode-hz
  82. :pre-write-conversion 'pre-write-encode-hz)
  83. (define-coding-system-alias 'hz-gb-2312 'chinese-hz)
  84. (define-coding-system-alias 'hz 'chinese-hz)
  85. (set-language-info-alist
  86. "Chinese-GB" '((charset chinese-gb2312 chinese-sisheng)
  87. (iso639-language . zh)
  88. (setup-function . (lambda ()
  89. (use-cjk-char-width-table 'zh_CN)))
  90. (exit-function . use-default-char-width-table)
  91. (coding-system chinese-iso-8bit iso-2022-cn chinese-hz)
  92. (coding-priority chinese-iso-8bit chinese-big5 iso-2022-cn)
  93. (input-method . "chinese-py-punct")
  94. (features china-util)
  95. (sample-text . "Chinese ($AVPND(B,$AFUM(;0(B,$A::So(B) $ADc:C(B")
  96. (documentation . "Support for Chinese GB2312 character set.")
  97. (tutorial . "TUTORIAL.cn"))
  98. '("Chinese"))
  99. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  100. ;; Chinese BIG5 (traditional)
  101. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  102. (define-coding-system 'chinese-big5
  103. "BIG5 8-bit encoding for Chinese (MIME:Big5)"
  104. :coding-type 'big5
  105. :mnemonic ?B
  106. :charset-list '(ascii big5)
  107. :mime-charset 'big5)
  108. (define-coding-system-alias 'big5 'chinese-big5)
  109. (define-coding-system-alias 'cn-big5 'chinese-big5)
  110. (define-coding-system-alias 'cp950 'chinese-big5)
  111. (set-language-info-alist
  112. "Chinese-BIG5" '((charset chinese-big5-1 chinese-big5-2)
  113. (iso639-language . zh)
  114. (setup-function . (lambda ()
  115. (use-cjk-char-width-table 'zh_HK)))
  116. (exit-function . use-default-char-width-table)
  117. (coding-system chinese-big5 chinese-iso-7bit)
  118. (coding-priority chinese-big5 iso-2022-cn chinese-iso-8bit)
  119. (input-method . "chinese-py-punct-b5")
  120. (ctext-non-standard-encodings "big5-0")
  121. (features china-util)
  122. (sample-text . "Cantonese ($(0GnM$(B,$(0N]0*Hd(B) $(0*/=((B, $(0+$)p(B")
  123. (documentation . "Support for Chinese Big5 character set.")
  124. (tutorial . "TUTORIAL.zh"))
  125. '("Chinese"))
  126. (define-coding-system 'chinese-big5-hkscs
  127. "BIG5-HKSCS 8-bit encoding for Chinese, Hong Kong supplement (MIME:Big5-HKSCS)"
  128. :coding-type 'charset
  129. :mnemonic ?B
  130. :charset-list '(ascii big5-hkscs)
  131. :mime-charset 'big5-hkscs)
  132. (define-coding-system-alias 'big5-hkscs 'chinese-big5-hkscs)
  133. (define-coding-system-alias 'cn-big5-hkscs 'chinese-big5-hkscs)
  134. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  135. ;; Chinese CNS11643 (traditional)
  136. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  137. (define-coding-system 'euc-tw
  138. "ISO 2022 based EUC encoding for Chinese CNS11643."
  139. :coding-type 'iso-2022
  140. :mnemonic ?Z
  141. :charset-list '(ascii
  142. chinese-cns11643-1
  143. chinese-cns11643-2
  144. chinese-cns11643-3
  145. chinese-cns11643-4
  146. chinese-cns11643-5
  147. chinese-cns11643-6
  148. chinese-cns11643-7)
  149. :designation [ascii chinese-cns11643-1 (chinese-cns11643-1
  150. chinese-cns11643-2
  151. chinese-cns11643-3
  152. chinese-cns11643-4
  153. chinese-cns11643-5
  154. chinese-cns11643-6
  155. chinese-cns11643-7) nil]
  156. :mime-charset 'euc-tw)
  157. (define-coding-system-alias 'euc-taiwan 'euc-tw)
  158. (set-language-info-alist
  159. "Chinese-CNS" '((charset chinese-cns11643-1 chinese-cns11643-2
  160. chinese-cns11643-3 chinese-cns11643-4
  161. chinese-cns11643-5 chinese-cns11643-6
  162. chinese-cns11643-7)
  163. (iso639-language . zh)
  164. (setup-function . (lambda ()
  165. (use-cjk-char-width-table 'zh_TW)))
  166. (exit-function . use-default-char-width-table)
  167. (coding-system iso-2022-cn euc-tw)
  168. (coding-priority iso-2022-cn euc-tw chinese-big5
  169. chinese-iso-8bit)
  170. (features china-util)
  171. (input-method . "chinese-cns-quick")
  172. ;; Fixme: presumably it won't accept big5 now.
  173. (documentation . "\
  174. Support for Chinese CNS character sets. Note that the EUC-TW coding system
  175. accepts Big5 for input also (which is then converted to CNS)."))
  176. '("Chinese"))
  177. (set-language-info-alist
  178. "Chinese-EUC-TW" '((charset chinese-cns11643-1 chinese-cns11643-2
  179. chinese-cns11643-3 chinese-cns11643-4
  180. chinese-cns11643-5 chinese-cns11643-6
  181. chinese-cns11643-7 chinese-big5-1 chinese-big5-2)
  182. (iso639-language . zh)
  183. (setup-function . (lambda ()
  184. (use-cjk-char-width-table 'zh_TW)))
  185. (exit-function . use-default-char-width-table)
  186. (coding-system euc-tw iso-2022-cn)
  187. (coding-priority euc-tw chinese-big5 iso-2022-cn
  188. chinese-iso-8bit)
  189. (features china-util)
  190. (input-method . "chinese-cns-quick")
  191. (documentation . "\
  192. Support for Chinese, preferring the EUC-TW character set. Note that
  193. the EUC-TW coding system accepts Big5 for input also (which is then
  194. converted to CNS)."))
  195. '("Chinese"))
  196. ;;; Chinese GBK
  197. (define-coding-system 'chinese-gbk
  198. "GBK encoding for Chinese (MIME:GBK)."
  199. :coding-type 'charset
  200. :mnemonic ?c
  201. :charset-list '(ascii chinese-gbk)
  202. :mime-charset 'gbk)
  203. (define-coding-system-alias 'gbk 'chinese-gbk)
  204. (define-coding-system-alias 'cp936 'chinese-gbk)
  205. (define-coding-system-alias 'windows-936 'chinese-gbk)
  206. (set-language-info-alist
  207. "Chinese-GBK" '((charset chinese-gbk)
  208. (iso639-language . zh)
  209. (setup-function . (lambda ()
  210. (use-cjk-char-width-table 'zh_CN)))
  211. (exit-function . use-default-char-width-table)
  212. (coding-system chinese-gbk)
  213. (coding-priority gbk iso-2022-cn chinese-big5
  214. chinese-iso-8bit) ; fixme?
  215. (ctext-non-standard-encodings "gbk-0")
  216. (input-method . "chinese-py-punct") ; fixme?
  217. (sample-text . "Chinese ($BCfJ8(B,$BIaDL$A;0(B,$A::So(B) $(D95$B9%(B")
  218. (features china-util)
  219. (documentation . "Support for Chinese GBK character set.")
  220. (tutorial . "TUTORIAL.cn"))
  221. '("Chinese"))
  222. ;;; Chinese GB18030
  223. (define-coding-system 'chinese-gb18030
  224. "GB18030 encoding for Chinese (MIME:GB18030)."
  225. :coding-type 'charset
  226. :mnemonic ?c
  227. :charset-list '(ascii gb18030-2-byte
  228. gb18030-4-byte-bmp gb18030-4-byte-smp
  229. gb18030-4-byte-ext-1 gb18030-4-byte-ext-2)
  230. :mime-charset 'gb18030)
  231. (define-coding-system-alias 'gb18030 'chinese-gb18030)
  232. (set-language-info-alist
  233. "Chinese-GB18030" '((charset gb18030)
  234. (iso639-language . zh)
  235. (coding-system chinese-gb18030)
  236. (coding-priority gb18030 gbk iso-2022-cn chinese-big5
  237. chinese-iso-8bit) ; fixme?
  238. (input-method . "chinese-py-punct") ; fixme?
  239. (sample-text . "Chinese ($BCfJ8(B,$BIaDL$A;0(B,$A::So(B) $(D0_$B9%(B")
  240. (features china-util)
  241. (documentation
  242. . "Support for Chinese GB18030 character set.")
  243. (tutorial . "TUTORIAL.cn"))
  244. '("Chinese"))
  245. ;; Fixme: add HKSCS
  246. (provide 'chinese)
  247. ;;; chinese.el ends here