Mercurial > hg > xemacs-beta
annotate lisp/mule/chinese.el @ 5157:1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
-------------------- ChangeLog entries follow: --------------------
lisp/ChangeLog addition:
2010-03-18 Ben Wing <ben@xemacs.org>
* diagnose.el (show-memory-usage):
Rewrite to take into account API changes in memory-usage functions.
src/ChangeLog addition:
2010-03-18 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (disksave_object_finalization_1):
* alloc.c (lisp_object_storage_size):
* alloc.c (listu):
* alloc.c (listn):
* alloc.c (Fobject_memory_usage_stats):
* alloc.c (compute_memusage_stats_length):
* alloc.c (Fobject_memory_usage):
* alloc.c (Ftotal_object_memory_usage):
* alloc.c (malloced_storage_size):
* alloc.c (common_init_alloc_early):
* alloc.c (reinit_alloc_objects_early):
* alloc.c (reinit_alloc_early):
* alloc.c (init_alloc_once_early):
* alloc.c (syms_of_alloc):
* alloc.c (reinit_vars_of_alloc):
* buffer.c:
* buffer.c (struct buffer_stats):
* buffer.c (compute_buffer_text_usage):
* buffer.c (compute_buffer_usage):
* buffer.c (buffer_memory_usage):
* buffer.c (buffer_objects_create):
* buffer.c (syms_of_buffer):
* buffer.c (vars_of_buffer):
* console-impl.h (struct console_methods):
* dynarr.c (Dynarr_memory_usage):
* emacs.c (main_1):
* events.c (clear_event_resource):
* extents.c:
* extents.c (compute_buffer_extent_usage):
* extents.c (extent_objects_create):
* extents.h:
* faces.c:
* faces.c (compute_face_cachel_usage):
* faces.c (face_objects_create):
* faces.h:
* general-slots.h:
* glyphs.c:
* glyphs.c (compute_glyph_cachel_usage):
* glyphs.c (glyph_objects_create):
* glyphs.h:
* lisp.h:
* lisp.h (struct usage_stats):
* lrecord.h:
* lrecord.h (enum lrecord_type):
* lrecord.h (struct lrecord_implementation):
* lrecord.h (MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE):
* lrecord.h (DEFINE_DUMPABLE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_FROB_BLOCK_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_SIZABLE_INTERNAL_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_FROB_BLOCK_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_INTERNAL_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_SIZABLE_INTERNAL_LISP_OBJECT):
* lrecord.h (MAKE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_MODULE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_MODULE_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_MODULE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_MODULE_SIZABLE_LISP_OBJECT):
* lrecord.h (MAKE_MODULE_LISP_OBJECT):
* lrecord.h (INIT_LISP_OBJECT):
* lrecord.h (INIT_MODULE_LISP_OBJECT):
* lrecord.h (UNDEF_LISP_OBJECT):
* lrecord.h (UNDEF_MODULE_LISP_OBJECT):
* lrecord.h (DECLARE_LISP_OBJECT):
* lrecord.h (DECLARE_MODULE_API_LISP_OBJECT):
* lrecord.h (DECLARE_MODULE_LISP_OBJECT):
* lstream.c:
* lstream.c (syms_of_lstream):
* lstream.c (vars_of_lstream):
* marker.c:
* marker.c (compute_buffer_marker_usage):
* mc-alloc.c (mc_alloced_storage_size):
* mc-alloc.h:
* mule-charset.c:
* mule-charset.c (struct charset_stats):
* mule-charset.c (compute_charset_usage):
* mule-charset.c (charset_memory_usage):
* mule-charset.c (mule_charset_objects_create):
* mule-charset.c (syms_of_mule_charset):
* mule-charset.c (vars_of_mule_charset):
* redisplay.c:
* redisplay.c (compute_rune_dynarr_usage):
* redisplay.c (compute_display_block_dynarr_usage):
* redisplay.c (compute_glyph_block_dynarr_usage):
* redisplay.c (compute_display_line_dynarr_usage):
* redisplay.c (compute_line_start_cache_dynarr_usage):
* redisplay.h:
* scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage):
* scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage):
* scrollbar-x.c (x_compute_scrollbar_instance_usage):
* scrollbar.c (compute_scrollbar_instance_usage):
* scrollbar.h:
* symbols.c:
* symbols.c (reinit_symbol_objects_early):
* symbols.c (init_symbols_once_early):
* symbols.c (reinit_symbols_early):
* symbols.c (defsymbol_massage_name_1):
* symsinit.h:
* ui-gtk.c:
* ui-gtk.c (emacs_gtk_object_getprop):
* ui-gtk.c (emacs_gtk_object_putprop):
* ui-gtk.c (ui_gtk_objects_create):
* unicode.c (compute_from_unicode_table_size_1):
* unicode.c (compute_to_unicode_table_size_1):
* unicode.c (compute_from_unicode_table_size):
* unicode.c (compute_to_unicode_table_size):
* window.c:
* window.c (struct window_stats):
* window.c (compute_window_mirror_usage):
* window.c (compute_window_usage):
* window.c (window_memory_usage):
* window.c (window_objects_create):
* window.c (syms_of_window):
* window.c (vars_of_window):
* window.h:
Redo memory-usage mechanism, make it general; add way of dynamically
initializing Lisp object types -- OBJECT_HAS_METHOD(), similar to
CONSOLE_HAS_METHOD().
(1) Create OBJECT_HAS_METHOD(), OBJECT_HAS_PROPERTY() etc. for
specifying that a Lisp object type has a particular method or
property. Call such methods with OBJECT_METH, MAYBE_OBJECT_METH,
OBJECT_METH_OR_GIVEN; retrieve properties with OBJECT_PROPERTY.
Methods that formerly required a DEFINE_*GENERAL_LISP_OBJECT() to
specify them (getprop, putprop, remprop, plist, disksave) now
instead use the dynamic-method mechanism. The main benefit of
this is that new methods or properties can be added without
requiring that the declaration statements of all existing methods
be modified. We have to make the `struct lrecord_implementation'
non-const, but I don't think this should have any effect on speed --
the only possible method that's really speed-critical is the
mark method, and we already extract those out into a separate
(non-const) array for increased cache locality.
Object methods need to be reinitialized after pdump, so we put
them in separate functions such as face_objects_create(),
extent_objects_create() and call them appropriately from emacs.c
The only current object property (`memusage_stats_list') that
objects can specify is a Lisp object and gets staticpro()ed so it
only needs to be set during dump time, but because it references
symbols that might not exist in a syms_of_() function, we
initialize it in vars_of_(). There is also an object property
(`num_extra_memusage_stats') that is automatically initialized based
on `memusage_stats_list'; we do that in reinit_vars_of_alloc(),
which is called after all vars_of_() functions are called.
`disksaver' method was renamed `disksave' to correspond with the
name normally given to the function (e.g. disksave_lstream()).
(2) Generalize the memory-usage mechanism in `buffer-memory-usage',
`window-memory-usage', `charset-memory-usage' into an object-type-
specific mechanism called by a single function
`object-memory-usage'. (Former function `object-memory-usage'
renamed to `total-object-memory-usage'). Generalize the mechanism
of different "slices" so that we can have different "classes" of
memory described and different "slices" onto each class; `t'
separates classes, `nil' separates slices. Currently we have
three classes defined: the memory of an object itself,
non-Lisp-object memory associated with the object (e.g. arrays or
dynarrs stored as fields in the object), and Lisp-object memory
associated with the object (other internal Lisp objects stored in
the object). This isn't completely finished yet and we might need
to further separate the "other internal Lisp objects" class into
two classes.
The memory-usage mechanism uses a `struct usage_stats' (renamed
from `struct overhead_stats') to describe a malloc-view onto a set
of allocated memory (listing how much was requested and various
types of overhead) and a more general `struct generic_usage_stats'
(with a `struct usage_stats' in it) to hold all statistics about
object memory. `struct generic_usage_stats' contains an array of
32 Bytecounts, which are statistics of unspecified semantics. The
intention is that individual types declare a corresponding struct
(e.g. `struct window_stats') with the same structure but with
specific fields in place of the array, corresponding to specific
statistics. The number of such statistics is an object property
computed from the list of tags (Lisp symbols describing the
statistics) stored in `memusage_stats_list'. The idea here is to
allow particular object types to customize the number and
semantics of the statistics where completely avoiding consing.
This doesn't matter so much yet, but the intention is to have the
memory usage of all objects computed at the end of GC, at the same
time as other statistics are currently computed. The values for
all statistics for a single type would be added up to compute
aggregate values for all objects of a specific type. To make this
efficient, we can't allow any memory allocation at all.
(3) Create some additional functions for creating lists that
specify the elements directly as args rather than indirectly through
an array: listn() (number of args given), listu() (list terminated
by Qunbound).
(4) Delete a bit of remaining unused C window_config stuff, also
unused lrecord_type_popup_data.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 18 Mar 2010 10:50:06 -0500 |
parents | 1d74a1d115ee |
children | 308d34e9f07d |
rev | line source |
---|---|
428 | 1 ;;; chinese.el --- Support for Chinese -*- coding: iso-2022-7bit; -*- |
2 | |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
4 ;; Licensed to the Free Software Foundation. | |
5 ;; Copyright (C) 1997 MORIOKA Tomohiko | |
776 | 6 ;; Copyright (C) 2000, 2001, 2002 Ben Wing. |
428 | 7 |
8 ;; Keywords: multilingual, Chinese | |
9 | |
10 ;; This file is part of XEmacs. | |
11 | |
12 ;; XEmacs is free software; you can redistribute it and/or modify it | |
13 ;; under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; XEmacs is distributed in the hope that it will be useful, but | |
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 ;; General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
25 ;; 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; For Chinese, three character sets GB2312, BIG5, and CNS11643 are | |
30 ;; supported. | |
31 | |
32 ;;; Code: | |
33 | |
4080 | 34 (eval-when-compile (progn (require 'ccl) (require 'china-util))) |
778 | 35 |
428 | 36 ;; Syntax of Chinese characters. |
37 (loop for row in '(33 34 41) | |
38 do (modify-syntax-entry `[chinese-gb2312 ,row] ".")) | |
778 | 39 |
428 | 40 ;; CNS11643 Plane3 thru Plane7 |
41 ;; These represent more and more obscure Chinese characters. | |
42 ;; By the time you get to Plane 7, we're talking about characters | |
43 ;; that appear once in some ancient manuscript and whose meaning | |
44 ;; is unknown. | |
45 | |
46 (flet | |
47 ((make-chinese-cns11643-charset | |
48 (name plane final) | |
49 (make-charset | |
50 name (concat "CNS 11643 Plane " plane " (Chinese traditional)") | |
3659 | 51 `(registries |
52 ,(vector (concat "cns11643.1992-" plane )) | |
428 | 53 dimension 2 |
54 chars 94 | |
55 final ,final | |
778 | 56 graphic 0 |
57 short-name ,(concat "CNS11643-" plane) | |
58 long-name ,(format "CNS11643-%s (Chinese traditional): ISO-IR-183" | |
59 plane))) | |
428 | 60 (modify-syntax-entry name "w") |
61 (modify-category-entry name ?t) | |
62 )) | |
63 (make-chinese-cns11643-charset 'chinese-cns11643-3 "3" ?I) | |
64 (make-chinese-cns11643-charset 'chinese-cns11643-4 "4" ?J) | |
65 (make-chinese-cns11643-charset 'chinese-cns11643-5 "5" ?K) | |
66 (make-chinese-cns11643-charset 'chinese-cns11643-6 "6" ?L) | |
67 (make-chinese-cns11643-charset 'chinese-cns11643-7 "7" ?M) | |
68 ) | |
69 | |
70 ;; ISO-IR-165 (CCITT Extended GB) | |
71 ;; It is based on CCITT Recommendation T.101, includes GB 2312-80 + | |
72 ;; GB 8565-88 table A4 + 293 characters. | |
778 | 73 (make-charset ;; not in FSF 21.1 |
428 | 74 'chinese-isoir165 |
75 "ISO-IR-165 (CCITT Extended GB; Chinese simplified)" | |
3659 | 76 `(registries ["isoir165-0"] |
428 | 77 dimension 2 |
78 chars 94 | |
79 final ?E | |
778 | 80 graphic 0 |
81 short-name "ISO-IR-165" | |
82 long-name "ISO-IR-165 (CCITT Extended GB; Chinese simplified)")) | |
428 | 83 |
84 ;; PinYin-ZhuYin | |
778 | 85 (make-charset 'chinese-sisheng |
86 "SiSheng characters for PinYin/ZhuYin" | |
87 '(dimension | |
88 1 | |
89 ;; XEmacs addition: second half of registry spec | |
3659 | 90 registries ["omron_udc_zh-0" "sisheng_cwnn-0"] |
428 | 91 chars 94 |
778 | 92 columns 1 |
93 direction l2r | |
428 | 94 final ?0 |
95 graphic 0 | |
778 | 96 short-name "SiSheng" |
97 long-name "SiSheng (PinYin/ZhuYin)" | |
428 | 98 )) |
99 | |
100 ;; If you prefer QUAIL to EGG, please modify below as you wish. | |
101 ;;(when (and (featurep 'egg) (featurep 'wnn)) | |
102 ;; (setq wnn-server-type 'cserver) | |
103 ;; (load "pinyin") | |
104 ;; (setq its:*standard-modes* | |
105 ;; (cons (its:get-mode-map "PinYin") its:*standard-modes*))) | |
106 | |
107 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
108 ;;; Chinese (general) | |
109 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
110 | |
111 ;; (make-coding-system | |
112 ;; 'iso-2022-cn 2 ?C | |
113 ;; "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN)" | |
114 ;; '(ascii | |
115 ;; (nil chinese-gb2312 chinese-cns11643-1) | |
116 ;; (nil chinese-cns11643-2) | |
117 ;; nil | |
118 ;; nil ascii-eol ascii-cntl seven locking-shift single-shift nil nil nil | |
119 ;; init-bol) | |
120 ;; '((safe-charsets ascii chinese-gb2312 chinese-cns11643-1 chinese-cns11643-2) | |
121 ;; (mime-charset . iso-2022-cn))) | |
122 | |
123 ;; (define-coding-system-alias 'chinese-iso-7bit 'iso-2022-cn) | |
124 | |
125 ;; (make-coding-system | |
126 ;; 'iso-2022-cn-ext 2 ?C | |
127 ;; "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN-EXT)" | |
128 ;; '(ascii | |
129 ;; (nil chinese-gb2312 chinese-cns11643-1) | |
130 ;; (nil chinese-cns11643-2) | |
131 ;; (nil chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5 | |
132 ;; chinese-cns11643-6 chinese-cns11643-7) | |
133 ;; nil ascii-eol ascii-cntl seven locking-shift single-shift nil nil nil | |
134 ;; init-bol) | |
135 ;; '((safe-charsets ascii chinese-gb2312 chinese-cns11643-1 chinese-cns11643-2 | |
136 ;; chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5 | |
137 ;; chinese-cns11643-6 chinese-cns11643-7) | |
138 ;; (mime-charset . iso-2022-cn-ext))) | |
139 | |
140 | |
141 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
142 ;;; Chinese GB2312 (simplified) | |
143 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
144 | |
145 ;; (make-coding-system | |
146 ;; 'chinese-iso-8bit 2 ?c | |
147 ;; "ISO 2022 based EUC encoding for Chinese GB2312 (MIME:CN-GB-2312)" | |
148 ;; '(ascii chinese-gb2312 nil nil | |
149 ;; nil ascii-eol ascii-cntl nil nil nil nil) | |
150 ;; '((safe-charsets ascii chinese-gb2312) | |
151 ;; (mime-charset . cn-gb-2312))) | |
152 | |
153 (make-coding-system | |
154 'cn-gb-2312 'iso2022 | |
771 | 155 "Chinese EUC" |
428 | 156 '(charset-g0 ascii |
157 charset-g1 chinese-gb2312 | |
778 | 158 charset-g2 chinese-sisheng |
428 | 159 charset-g3 t |
4568
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4145
diff
changeset
|
160 safe-charsets (ascii chinese-gb2312 chinese-sisheng) |
428 | 161 mnemonic "Zh-GB/EUC" |
771 | 162 documentation |
163 "Chinese EUC (Extended Unix Code), the standard Chinese encoding on Unix. | |
164 This follows the same overall EUC principles as Japanese EUC (see the | |
165 description under Japanese EUC), but specifies different character sets: | |
166 | |
167 G0: ASCII | |
168 G1: Chinese-GB2312 | |
169 G2: Sisheng (PinYin - ZhuYin)" | |
428 | 170 )) |
171 | |
3172 | 172 ;; For consistency with euc-jp, euc-ko |
173 (define-coding-system-alias 'euc-cn 'cn-gb-2312) | |
428 | 174 |
175 (define-coding-system-alias 'gb2312 'cn-gb-2312) | |
176 (define-coding-system-alias 'chinese-euc 'cn-gb-2312) | |
177 | |
178 ;; (make-coding-system | |
179 ;; 'chinese-hz 0 ?z | |
180 ;; "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)" | |
181 ;; nil | |
182 ;; '((safe-charsets ascii chinese-gb2312) | |
183 ;; (mime-charset . hz-gb-2312) | |
184 ;; (post-read-conversion . post-read-decode-hz) | |
185 ;; (pre-write-conversion . pre-write-encode-hz))) | |
186 ;; (put 'chinese-hz 'post-read-conversion 'post-read-decode-hz) | |
187 ;; (put 'chinese-hz 'pre-write-conversion 'pre-write-encode-hz) | |
188 | |
189 (make-coding-system | |
190 'hz-gb-2312 'no-conversion | |
771 | 191 "Hz/ZW (Chinese)" |
428 | 192 '(mnemonic "Zh-GB/Hz" |
193 eol-type lf | |
4568
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4145
diff
changeset
|
194 safe-charsets (ascii chinese-gb2312) |
428 | 195 post-read-conversion post-read-decode-hz |
771 | 196 pre-write-conversion pre-write-encode-hz |
197 documentation "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)" | |
198 )) | |
428 | 199 |
200 ;; (define-coding-system-alias 'hz-gb-2312 'chinese-hz) | |
201 ;; (define-coding-system-alias 'hz 'chinese-hz) | |
202 | |
203 (define-coding-system-alias 'hz 'hz-gb-2312) | |
204 | |
205 (defun post-read-decode-hz (len) | |
206 (let ((pos (point)) | |
207 (buffer-modified-p (buffer-modified-p)) | |
776 | 208 ;last-coding-system-used |
209 ) | |
428 | 210 (prog1 |
211 (decode-hz-region pos (+ pos len)) | |
212 (set-buffer-modified-p buffer-modified-p)))) | |
213 | |
214 (defun pre-write-encode-hz (from to) | |
215 (let ((buf (current-buffer))) | |
216 (set-buffer (generate-new-buffer " *temp*")) | |
217 (if (stringp from) | |
218 (insert from) | |
219 (insert-buffer-substring buf from to)) | |
776 | 220 ;(let (last-coding-system-used) |
221 (encode-hz-region 1 (point-max)) | |
428 | 222 nil)) |
771 | 223 |
428 | 224 (set-language-info-alist |
225 "Chinese-GB" '((setup-function . setup-chinese-gb-environment-internal) | |
778 | 226 (charset chinese-gb2312 chinese-sisheng) |
428 | 227 (coding-system cn-gb-2312 iso-2022-7bit hz-gb-2312) |
228 (coding-priority cn-gb-2312 big5 iso-2022-7bit) | |
771 | 229 (cygwin-locale "zh") |
230 (mswindows-locale ("CHINESE" . "CHINESE_SIMPLIFIED")) | |
231 (native-coding-system cn-gb-2312) | |
428 | 232 (input-method . "chinese-py-punct") |
233 (features china-util) | |
234 (sample-text . "Chinese ($AVPND(B,$AFUM(;0(B,$A::So(B) $ADc:C(B") | |
771 | 235 (documentation . |
236 "Supports Simplified Chinese, used in mainland China. | |
237 Uses the GB2312 character set.")) | |
428 | 238 '("Chinese")) |
239 | |
4145 | 240 ;; Set the locale information separately so that the lambda gets compiled. |
241 (set-language-info "Chinese-GB" | |
242 'locale | |
243 (list "zh_CN.eucCN" "zh_CN.EUC" "zh_CN" "chinese-s" "zh" | |
244 (lambda (arg) | |
245 (and arg (let ((case-fold-search t)) | |
246 (string-match "^zh_.*.GB.*" arg)))))) | |
247 | |
428 | 248 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
249 ;; Chinese BIG5 (traditional) | |
250 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
251 | |
252 ;; (make-coding-system | |
253 ;; 'chinese-big5 3 ?B "BIG5 8-bit encoding for Chinese (MIME:CN-BIG5)" | |
254 ;; nil | |
255 ;; '((safe-charsets ascii chinese-big5-1 chinese-big5-2) | |
256 ;; (mime-charset . cn-big5) | |
257 ;; (charset-origin-alist (chinese-big5-1 "BIG5" encode-big5-char) | |
258 ;; (chinese-big5-2 "BIG5" encode-big5-char)))) | |
259 | |
260 (make-coding-system | |
261 'big5 'big5 | |
771 | 262 "Big5" |
263 '(mnemonic "Zh/Big5" | |
4568
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4145
diff
changeset
|
264 safe-charsets (ascii chinese-big5-1 chinese-big5-2) |
771 | 265 documentation |
266 "A non-modal encoding formed by five large Taiwanese companies | |
267 \(hence \"Big5\") to produce a character set and encoding for | |
268 traditional Chinese writing. Big5 encodes some 13,000+ characters. | |
269 ASCII is encoded as normal, and Chinese characters as two bytes, but | |
270 Chinese characters do not exclusively use the high half. The first | |
271 byte is in the high half standard position A1-FE, but the second byte | |
272 is in either low 40-7E or high A1-FE. Thus Big5 suffers from the | |
273 classic \"it might look like a slash, but it's really the second byte | |
274 of a Chinese character\".")) | |
428 | 275 |
276 ;; (define-coding-system-alias 'big5 'chinese-big5) | |
277 ;; (define-coding-system-alias 'cn-big5 'chinese-big5) | |
278 | |
279 (define-coding-system-alias 'cn-big5 'big5) | |
280 | |
281 ;; Big5 font requires special encoding. | |
282 (define-ccl-program ccl-encode-big5-font | |
283 `(0 | |
284 ;; In: R0:chinese-big5-1 or chinese-big5-2 | |
285 ;; R1:position code 1 | |
286 ;; R2:position code 2 | |
287 ;; Out: R1:font code point 1 | |
288 ;; R2:font code point 2 | |
4072 | 289 ((r2 = ((((r1 - #x21) * 94) + r2) - #x21)) |
428 | 290 (if (r0 == ,(charset-id 'chinese-big5-2)) (r2 += 6280)) |
4072 | 291 (r1 = ((r2 / 157) + #xA1)) |
428 | 292 (r2 %= 157) |
4072 | 293 (if (r2 < #x3F) (r2 += #x40) (r2 += #x62)))) |
428 | 294 "CCL program to encode a Big5 code to code point of Big5 font.") |
295 | |
444 | 296 (set-charset-ccl-program 'chinese-big5-1 'ccl-encode-big5-font) |
297 (set-charset-ccl-program 'chinese-big5-2 'ccl-encode-big5-font) | |
428 | 298 |
299 (set-language-info-alist | |
300 "Chinese-BIG5" '((charset chinese-big5-1 chinese-big5-2) | |
301 (coding-system big5 iso-2022-7bit) | |
302 (coding-priority big5 cn-gb-2312 iso-2022-7bit) | |
771 | 303 (cygwin-locale "zh_TW") |
304 (mswindows-locale ("CHINESE" . "CHINESE_TRADITIONAL")) | |
305 (native-coding-system big5) | |
428 | 306 (input-method . "chinese-py-punct-b5") |
307 (features china-util) | |
308 (sample-text . "Cantonese ($(0GnM$(B,$(0N]0*Hd(B) $(0*/=((B, $(0+$)p(B") | |
771 | 309 (documentation . |
310 "Supports Traditional Chinese, used in Taiwan, Hong Kong, and Singapore. | |
311 Uses the Chinese Big5 character set." | |
312 )) | |
428 | 313 '("Chinese")) |
314 | |
4145 | 315 ;; Set the locale information separately so that the lambda gets compiled. |
316 (set-language-info "Chinese-BIG5" | |
317 'locale | |
318 (list "zh_TW.Big5" "zh_TW.big5" "zh_CN.big5" "zh_TW" | |
319 "chinese-t" | |
320 (lambda (arg) | |
321 (and arg (let ((case-fold-search t)) | |
322 (string-match "^zh_.*.BIG5.*" arg)))))) | |
323 | |
428 | 324 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
325 ;; Chinese CNS11643 (traditional) | |
326 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
327 | |
328 ;; (set-language-info-alist | |
329 ;; "Chinese-CNS" '((charset chinese-cns11643-1 chinese-cns11643-2 | |
330 ;; chinese-cns11643-3 chinese-cns11643-4 | |
331 ;; chinese-cns11643-5 chinese-cns11643-6 | |
332 ;; chinese-cns11643-7) | |
333 ;; (coding-system iso-2022-cn) | |
334 ;; (coding-priority iso-2022-cn chinese-big5 chinese-iso-8bit) | |
335 ;; (features china-util) | |
336 ;; (input-method . "chinese-cns-quick") | |
337 ;; (documentation . "Support for Chinese CNS character sets.")) | |
338 ;; '("Chinese")) | |
339 | |
340 ;;; chinese.el ends here |