annotate lisp/unicode.el @ 4202:a7c5de5b9880

[xemacs-hg @ 2007-10-02 10:33:04 by aidan] Fix some bugs in the Unicode error sequence Lisp API.
author aidan
date Tue, 02 Oct 2007 10:33:05 +0000
parents edb00a8b4eff
children 3651e9c49476
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
1 ;;; unicode.el --- Unicode support -*- coding: iso-2022-7bit; -*-
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
2
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
3 ;; Copyright (C) 2001, 2002 Ben Wing.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
4
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
5 ;; Keywords: multilingual, Unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
6
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
7 ;; This file is part of XEmacs.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
8
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
12 ;; any later version.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
13
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
17 ;; General Public License for more details.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
18
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
22 ;; 02111-1307, USA.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
23
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
24 ;;; Synched up with: Not in FSF.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
25
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
26 ;;; Commentary:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
27
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
28 ;; Lisp support for Unicode, e.g. initialize the translation tables.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
29
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
30 ;;; Code:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
31
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
32 ;; GNU Emacs has the charsets:
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
33
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
34 ;; mule-unicode-2500-33ff
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
35 ;; mule-unicode-e000-ffff
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
36 ;; mule-unicode-0100-24ff
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
37
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
38 ;; built-in. This is hack--and an incomplete hack at that--against the
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
39 ;; spirit and the letter of standard ISO 2022 character sets. Instead of
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
40 ;; this, we have the jit-ucs-charset-N Mule character sets, created in
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
41 ;; unicode.c on encountering a Unicode code point that we don't recognise,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
42 ;; and saved in ISO 2022 coding systems using the UTF-8 escape described in
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
43 ;; ISO-IR 196.
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
44
4083
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
45 (eval-when-compile (when (featurep 'mule) (require 'ccl)))
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
46
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2297
diff changeset
47 ;; accessed in loadup.el, mule-cmds.el; see discussion in unicode.c
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2297
diff changeset
48 (defvar load-unicode-tables-at-dump-time (eq system-type 'windows-nt)
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2297
diff changeset
49 "[INTERNAL] Whether to load the Unicode tables at dump time.
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2297
diff changeset
50 Setting this at run-time does nothing.")
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2297
diff changeset
51
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
52 ;; NOTE: This takes only a fraction of a second on my Pentium III
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
53 ;; 700Mhz even with a totally optimization-disabled XEmacs.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
54 (defun load-unicode-tables ()
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
55 "Initialize the Unicode translation tables for all standard charsets."
780
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
56 (let ((parse-args
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
57 '(("unicode/unicode-consortium"
877
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 780
diff changeset
58 ;; Due to the braindamaged way Mule treats the ASCII and Control-1
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 780
diff changeset
59 ;; charsets' types, trying to load them results in out-of-range
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 780
diff changeset
60 ;; warnings at unicode.c:1439. They're no-ops anyway, they're
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 780
diff changeset
61 ;; hardwired in unicode.c (unicode_to_ichar, ichar_to_unicode).
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 780
diff changeset
62 ;; ("8859-1.TXT" ascii #x00 #x7F #x0)
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 780
diff changeset
63 ;; ("8859-1.TXT" control-1 #x80 #x9F #x-80)
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 780
diff changeset
64 ;; The 8859-1.TXT G1 assignments are half no-ops, hardwired in
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 780
diff changeset
65 ;; unicode.c ichar_to_unicode, but not in unicode_to_ichar.
780
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
66 ("8859-1.TXT" latin-iso8859-1 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
67 ;; "8859-10.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
68 ;; "8859-13.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
69 ("8859-14.TXT" latin-iso8859-14 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
70 ("8859-15.TXT" latin-iso8859-15 #xA0 #xFF #x-80)
2575
e71117a6ddac [xemacs-hg @ 2005-02-09 15:29:07 by aidan]
aidan
parents: 2574
diff changeset
71 ("8859-16.TXT" latin-iso8859-16 #xA0 #xFF #x-80)
780
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
72 ("8859-2.TXT" latin-iso8859-2 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
73 ("8859-3.TXT" latin-iso8859-3 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
74 ("8859-4.TXT" latin-iso8859-4 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
75 ("8859-5.TXT" cyrillic-iso8859-5 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
76 ("8859-6.TXT" arabic-iso8859-6 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
77 ("8859-7.TXT" greek-iso8859-7 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
78 ("8859-8.TXT" hebrew-iso8859-8 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
79 ("8859-9.TXT" latin-iso8859-9 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
80 ;; charset for Big5 does not matter; specifying `big5' will
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
81 ;; automatically make the right thing happen
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
82 ("BIG5.TXT" chinese-big5-1 nil nil nil big5)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
83 ("CNS11643.TXT" chinese-cns11643-1 #x10000 #x1FFFF #x-10000)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
84 ("CNS11643.TXT" chinese-cns11643-2 #x20000 #x2FFFF #x-20000)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
85 ;; "CP1250.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
86 ;; "CP1251.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
87 ;; "CP1252.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
88 ;; "CP1253.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
89 ;; "CP1254.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
90 ;; "CP1255.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
91 ;; "CP1256.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
92 ;; "CP1257.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
93 ;; "CP1258.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
94 ;; "CP874.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
95 ;; "CP932.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
96 ;; "CP936.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
97 ;; "CP949.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
98 ;; "CP950.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
99 ;; "GB12345.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
100 ("GB2312.TXT" chinese-gb2312)
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1318
diff changeset
101 ;; "HANGUL.TXT"
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1318
diff changeset
102 ;; #### shouldn't JIS X 0201's upper limit be 7f?
780
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
103 ("JIS0201.TXT" latin-jisx0201 #x21 #x80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
104 ("JIS0201.TXT" katakana-jisx0201 #xA0 #xFF #x-80)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
105 ("JIS0208.TXT" japanese-jisx0208 nil nil nil ignore-first-column)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
106 ("JIS0212.TXT" japanese-jisx0212)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
107 ;; "JOHAB.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
108 ;; "KOI8-R.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
109 ;; "KSC5601.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
110 ;; note that KSC5601.TXT as currently distributed is NOT what
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
111 ;; it claims to be! see comments in KSX1001.TXT.
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
112 ("KSX1001.TXT" korean-ksc5601)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
113 ;; "OLD5601.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
114 ;; "SHIFTJIS.TXT"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
115 )
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
116 ("unicode/mule-ucs"
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1318
diff changeset
117 ;; #### we don't support surrogates?!??
780
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
118 ;; use these instead of the above ones once we support surrogates
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
119 ;;("chinese-cns11643-1.txt" chinese-cns11643-1)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
120 ;;("chinese-cns11643-2.txt" chinese-cns11643-2)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
121 ;;("chinese-cns11643-3.txt" chinese-cns11643-3)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
122 ;;("chinese-cns11643-4.txt" chinese-cns11643-4)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
123 ;;("chinese-cns11643-5.txt" chinese-cns11643-5)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
124 ;;("chinese-cns11643-6.txt" chinese-cns11643-6)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
125 ;;("chinese-cns11643-7.txt" chinese-cns11643-7)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
126 ("chinese-sisheng.txt" chinese-sisheng)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
127 ("ethiopic.txt" ethiopic)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
128 ("indian-is13194.txt" indian-is13194)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
129 ("ipa.txt" ipa)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
130 ("thai-tis620.txt" thai-tis620)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
131 ("tibetan.txt" tibetan)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
132 ("vietnamese-viscii-lower.txt" vietnamese-viscii-lower)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
133 ("vietnamese-viscii-upper.txt" vietnamese-viscii-upper)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
134 )
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
135 ("unicode/other"
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
136 ("lao.txt" lao)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
137 )
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
138 )))
780
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
139 (mapcar #'(lambda (tables)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
140 (let ((undir
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
141 (expand-file-name (car tables) data-directory)))
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
142 (mapcar #'(lambda (args)
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 985
diff changeset
143 (apply 'load-unicode-mapping-table
780
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
144 (expand-file-name (car args) undir)
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
145 (cdr args)))
578cb2932d72 [xemacs-hg @ 2002-03-18 10:07:30 by ben]
ben
parents: 778
diff changeset
146 (cdr tables))))
4145
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
147 parse-args)
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
148 ;; The default-unicode-precedence-list. We set this here to default to
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
149 ;; *not* mapping various European characters to East Asian characters;
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
150 ;; otherwise the default-unicode-precedence-list is numerically ordered
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
151 ;; by charset ID.
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
152 (set-default-unicode-precedence-list
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
153 '(ascii control-1 latin-iso8859-1 latin-iso8859-2 latin-iso8859-15
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
154 greek-iso8859-7 hebrew-iso8859-8 ipa cyrillic-iso8859-5
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
155 latin-iso8859-16 latin-iso8859-3 latin-iso8859-4 latin-iso8859-9
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
156 vietnamese-viscii-lower vietnamese-viscii-upper arabic-iso8859-6
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
157 jit-ucs-charset-0 japanese-jisx0208 japanese-jisx0208-1978
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
158 japanese-jisx0212 japanese-jisx0213-1 japanese-jisx0213-2
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
159 chinese-gb2312 chinese-sisheng chinese-big5-1 chinese-big5-2
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
160 indian-is13194 korean-ksc5601 chinese-cns11643-1 chinese-cns11643-2
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
161 chinese-isoir165 arabic-1-column arabic-2-column arabic-digit
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
162 composite ethiopic indian-1-column indian-2-column jit-ucs-charset-0
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
163 katakana-jisx0201 lao thai-tis620 thai-xtis tibetan tibetan-1-column
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
164 latin-jisx0201 chinese-cns11643-3 chinese-cns11643-4
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
165 chinese-cns11643-5 chinese-cns11643-6 chinese-cns11643-7))))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
166
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
167 (make-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
168 'utf-16 'unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
169 "UTF-16"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
170 '(mnemonic "UTF-16"
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
171 documentation
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
172 "UTF-16 Unicode encoding -- the standard (almost-) fixed-width
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
173 two-byte encoding, with surrogates. It will be fixed-width if all
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
174 characters are in the BMP (Basic Multilingual Plane -- first 65536
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
175 codepoints). Cannot represent characters with codepoints above
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
176 0x10FFFF (a little more than 1,000,000). Unicode and ISO guarantee
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
177 never to encode any characters outside this range -- all the rest are
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
178 for private, corporate or internal use."
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
179 unicode-type utf-16))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
180
2574
5e2653bc0ab0 [xemacs-hg @ 2005-02-08 23:59:50 by aidan]
aidan
parents: 2367
diff changeset
181 (define-coding-system-alias 'utf-16-be 'utf-16)
5e2653bc0ab0 [xemacs-hg @ 2005-02-08 23:59:50 by aidan]
aidan
parents: 2367
diff changeset
182
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
183 (make-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
184 'utf-16-bom 'unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
185 "UTF-16 w/BOM"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
186 '(mnemonic "UTF16-BOM"
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
187 documentation
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
188 "UTF-16 Unicode encoding with byte order mark (BOM) at the beginning.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
189 The BOM is Unicode character U+FEFF -- i.e. the first two bytes are
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
190 0xFE and 0xFF, respectively, or reversed in a little-endian
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
191 representation. It has been sanctioned by the Unicode Consortium for
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
192 use at the beginning of a Unicode stream as a marker of the byte order
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
193 of the stream, and commonly appears in Unicode files under Microsoft
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
194 Windows, where it also functions as a magic cookie identifying a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
195 Unicode file. The character is called \"ZERO WIDTH NO-BREAK SPACE\"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
196 and is suitable as a byte-order marker because:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
197
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
198 -- it has no displayable representation
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
199 -- due to its semantics it never normally appears at the beginning
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
200 of a stream
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
201 -- its reverse U+FFFE is not a legal Unicode character
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
202 -- neither byte sequence is at all likely in any other standard
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
203 encoding, particularly at the beginning of a stream
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
204
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
205 This coding system will insert a BOM at the beginning of a stream when
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
206 writing and strip it off when reading."
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
207 unicode-type utf-16
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
208 need-bom t))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
209
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
210 (make-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
211 'utf-16-little-endian 'unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
212 "UTF-16 Little Endian"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
213 '(mnemonic "UTF16-LE"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
214 documentation
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
215 "Little-endian version of UTF-16 Unicode encoding.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
216 See `utf-16' coding system."
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
217 unicode-type utf-16
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
218 little-endian t))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
219
2574
5e2653bc0ab0 [xemacs-hg @ 2005-02-08 23:59:50 by aidan]
aidan
parents: 2367
diff changeset
220 (define-coding-system-alias 'utf-16-le 'utf-16-little-endian)
5e2653bc0ab0 [xemacs-hg @ 2005-02-08 23:59:50 by aidan]
aidan
parents: 2367
diff changeset
221
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
222 (make-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
223 'utf-16-little-endian-bom 'unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
224 "UTF-16 Little Endian w/BOM"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
225 '(mnemonic "MSW-Unicode"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
226 documentation
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
227 "Little-endian version of UTF-16 Unicode encoding, with byte order mark.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
228 Standard encoding for representing Unicode under MS Windows. See
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
229 `utf-16-bom' coding system."
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
230 unicode-type utf-16
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
231 little-endian t
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
232 need-bom t))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
233
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
234 (make-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
235 'ucs-4 'unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
236 "UCS-4"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
237 '(mnemonic "UCS4"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
238 documentation
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
239 "UCS-4 Unicode encoding -- fully fixed-width four-byte encoding."
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
240 unicode-type ucs-4))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
241
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
242 (make-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
243 'ucs-4-little-endian 'unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
244 "UCS-4 Little Endian"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
245 '(mnemonic "UCS4-LE"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
246 documentation
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1318
diff changeset
247 ;; #### I don't think this is permitted by ISO 10646, only Unicode.
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1318
diff changeset
248 ;; Call it UTF-32 instead?
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
249 "Little-endian version of UCS-4 Unicode encoding. See `ucs-4' coding system."
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
250 unicode-type ucs-4
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
251 little-endian t))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
252
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
253 (make-coding-system
4096
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
254 'utf-32 'unicode
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
255 "UTF-32"
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
256 '(mnemonic "UTF32"
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
257 documentation
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
258 "UTF-32 Unicode encoding -- fixed-width four-byte encoding,
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
259 characters less than #x10FFFF are not supported. "
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
260 unicode-type utf-32))
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
261
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
262 (make-coding-system
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
263 'utf-32-little-endian 'unicode
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
264 "UTF-32 Little Endian"
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
265 '(mnemonic "UTF32-LE"
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
266 documentation
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
267 "Little-endian version of UTF-32 Unicode encoding.
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
268
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
269 A fixed-width four-byte encoding, characters less than #x10FFFF are not
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
270 supported. "
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
271 unicode-type ucs-4 little-endian t))
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
272
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
273 (make-coding-system
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
274 'utf-8 'unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
275 "UTF-8"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
276 '(mnemonic "UTF8"
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
277 documentation "
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
278 UTF-8 Unicode encoding -- ASCII-compatible 8-bit variable-width encoding
2297
13a418960a88 [xemacs-hg @ 2004-09-22 02:05:42 by stephent]
stephent
parents: 1318
diff changeset
279 sharing the following principles with the Mule-internal encoding:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
280
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
281 -- All ASCII characters (codepoints 0 through 127) are represented
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
282 by themselves (i.e. using one byte, with the same value as the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
283 ASCII codepoint), and these bytes are disjoint from bytes
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
284 representing non-ASCII characters.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
285
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
286 This means that any 8-bit clean application can safely process
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
287 UTF-8-encoded text as it were ASCII, with no corruption (e.g. a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
288 '/' byte is always a slash character, never the second byte of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
289 some other character, as with Big5, so a pathname encoded in
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
290 UTF-8 can safely be split up into components and reassembled
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
291 again using standard ASCII processes).
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
292
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
293 -- Leading bytes and non-leading bytes in the encoding of a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
294 character are disjoint, so moving backwards is easy.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
295
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
296 -- Given only the leading byte, you know how many following bytes
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
297 are present.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
298 "
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
299 unicode-type utf-8))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
300
985
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
301 (make-coding-system
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
302 'utf-8-bom 'unicode
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
303 "UTF-8 w/BOM"
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
304 '(mnemonic "MSW-UTF8"
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
305 documentation
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
306 "UTF-8 Unicode encoding, with byte order mark.
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
307 Standard encoding for representing UTF-8 under MS Windows."
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
308 unicode-type utf-8
985
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
309 little-endian t
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
310 need-bom t))
7f62a956b825 [xemacs-hg @ 2002-09-01 06:41:40 by youngs]
youngs
parents: 877
diff changeset
311
2633
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
312 (defun decode-char (quote-ucs code &optional restriction)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
313 "FSF compatibility--return Mule character with Unicode codepoint CODE.
2633
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
314 The second argument must be 'ucs, the third argument is ignored. "
4096
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
315 ;; We're prepared to accept invalid Unicode in unicode-to-char, but not in
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
316 ;; this function, which is the API that should actually be used, since
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
317 ;; it's available in GNU and in Mule-UCS.
1abf84db2c7f [xemacs-hg @ 2007-08-04 20:00:10 by aidan]
aidan
parents: 4083
diff changeset
318 (check-argument-range code #x0 #x10FFFF)
3506
bcc2611d4cfc [xemacs-hg @ 2006-07-13 20:45:48 by aidan]
aidan
parents: 3439
diff changeset
319 (assert (eq quote-ucs 'ucs) t
2633
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
320 "Sorry, decode-char doesn't yet support anything but the UCS. ")
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
321 (unicode-to-char code))
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
322
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
323 (defun encode-char (char quote-ucs &optional restriction)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
324 "FSF compatibility--return the Unicode code point of CHAR.
2633
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
325 The second argument must be 'ucs, the third argument is ignored. "
3506
bcc2611d4cfc [xemacs-hg @ 2006-07-13 20:45:48 by aidan]
aidan
parents: 3439
diff changeset
326 (assert (eq quote-ucs 'ucs) t
2633
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
327 "Sorry, encode-char doesn't yet support anything but the UCS. ")
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
328 (char-to-unicode char))
b921e3d0ac3e [xemacs-hg @ 2005-03-04 21:59:42 by aidan]
aidan
parents: 2575
diff changeset
329
3667
4c8ad140bcec [xemacs-hg @ 2006-11-07 18:51:21 by aidan]
aidan
parents: 3666
diff changeset
330 (when (featurep 'mule)
4083
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
331 (let ((prog
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
332 (eval-when-compile
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
333 (let ((pre-existing
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
334 ;; This is the compiled CCL program from the assert
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
335 ;; below. Since this file is dumped and ccl.el isn't (and
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
336 ;; even when it was, it was dumped much later than this
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
337 ;; one), we can't compile the program at dump time. We can
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
338 ;; check at byte compile time that the program is as
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
339 ;; expected, though.
4145
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
340 [1 16 131127 7 98872 65823 1307 5 -65536 65313 64833 1028
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
341 147513 8 82009 255 22]))
4083
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
342 (when (featurep 'mule)
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
343 ;; Check that the pre-existing constant reflects the intended
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
344 ;; CCL program.
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
345 (assert
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
346 (equal pre-existing
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
347 (ccl-compile
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
348 `(1
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
349 (;; mule-to-unicode's first argument is the
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
350 ;; charset ID, the second its first byte
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
351 ;; left shifted by 7 bits masked with its
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
352 ;; second byte.
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
353 (r1 = (r1 << 7))
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
354 (r1 = (r1 | r2))
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
355 (mule-to-unicode r0 r1)
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
356 (if (r0 & ,(lognot #xFFFF))
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
357 ;; Redisplay looks in r1 and r2 for the first
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
358 ;; and second bytes of the X11 font,
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
359 ;; respectively. For non-BMP characters we
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
360 ;; display U+FFFD.
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
361 ((r1 = #xFF)
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
362 (r2 = #xFD))
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
363 ((r1 = (r0 >> 8))
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
364 (r2 = (r0 & #xFF))))))))
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
365 nil
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
366 "The pre-compiled CCL program appears broken. "))
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
367 pre-existing))))
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
368 (defconst ccl-encode-to-ucs-2 prog
3667
4c8ad140bcec [xemacs-hg @ 2006-11-07 18:51:21 by aidan]
aidan
parents: 3666
diff changeset
369 "CCL program to transform Mule characters to UCS-2.")
4083
a3f8bb07ab38 [xemacs-hg @ 2007-07-28 08:02:15 by aidan]
aidan
parents: 4072
diff changeset
370 (put 'ccl-encode-to-ucs-2 'ccl-program-idx
4145
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
371 (register-ccl-program 'ccl-encode-to-ucs-2 prog)))
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
372
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
373 ;; Now, create jit-ucs-charset-0 entries for those characters in Windows
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
374 ;; Glyph List 4 that would otherwise end up in East Asian character sets.
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
375 ;;
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
376 ;; WGL4 is a character repertoire from Microsoft that gives a guideline
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
377 ;; for font implementors as to what characters are sufficient for
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
378 ;; pan-European support. The intention of this code is to avoid the
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
379 ;; situation where these characters end up mapping to East Asian XEmacs
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
380 ;; characters, which generally clash strongly with European characters
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
381 ;; both in font choice and character width; jit-ucs-charset-0 is a
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
382 ;; single-width character set which comes before the East Asian character
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
383 ;; sets in the default-unicode-precedence-list above.
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
384 (loop for (ucs ascii-or-latin-1)
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
385 in '((#x2013 ?-) ;; U+2013 EN DASH
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
386 (#x2014 ?-) ;; U+2014 EM DASH
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
387 (#x2105 ?%) ;; U+2105 CARE OF
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
388 (#x203e ?-) ;; U+203E OVERLINE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
389 (#x221f ?|) ;; U+221F RIGHT ANGLE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
390 (#x2584 ?|) ;; U+2584 LOWER HALF BLOCK
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
391 (#x2588 ?|) ;; U+2588 FULL BLOCK
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
392 (#x258c ?|) ;; U+258C LEFT HALF BLOCK
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
393 (#x2550 ?|) ;; U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
394 (#x255e ?|) ;; U+255E BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
395 (#x256a ?|) ;; U+256A BOX DRAWINGS VERTICAL SINGLE & HORIZONTAL DOUBLE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
396 (#x2561 ?|) ;; U+2561 BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
397 (#x2215 ?/) ;; U+2215 DIVISION SLASH
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
398 (#x02c9 ?`) ;; U+02C9 MODIFIER LETTER MACRON
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
399 (#x2211 ?s) ;; U+2211 N-ARY SUMMATION
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
400 (#x220f ?s) ;; U+220F N-ARY PRODUCT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
401 (#x2248 ?=) ;; U+2248 ALMOST EQUAL TO
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
402 (#x2264 ?=) ;; U+2264 LESS-THAN OR EQUAL TO
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
403 (#x2265 ?=) ;; U+2265 GREATER-THAN OR EQUAL TO
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
404 (#x201c ?') ;; U+201C LEFT DOUBLE QUOTATION MARK
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
405 (#x2026 ?.) ;; U+2026 HORIZONTAL ELLIPSIS
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
406 (#x2212 ?-) ;; U+2212 MINUS SIGN
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
407 (#x2260 ?=) ;; U+2260 NOT EQUAL TO
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
408 (#x221e ?=) ;; U+221E INFINITY
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
409 (#x2642 ?=) ;; U+2642 MALE SIGN
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
410 (#x2640 ?=) ;; U+2640 FEMALE SIGN
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
411 (#x2032 ?=) ;; U+2032 PRIME
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
412 (#x2033 ?=) ;; U+2033 DOUBLE PRIME
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
413 (#x25cb ?=) ;; U+25CB WHITE CIRCLE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
414 (#x25cf ?=) ;; U+25CF BLACK CIRCLE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
415 (#x25a1 ?=) ;; U+25A1 WHITE SQUARE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
416 (#x25a0 ?=) ;; U+25A0 BLACK SQUARE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
417 (#x25b2 ?=) ;; U+25B2 BLACK UP-POINTING TRIANGLE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
418 (#x25bc ?=) ;; U+25BC BLACK DOWN-POINTING TRIANGLE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
419 (#x2192 ?=) ;; U+2192 RIGHTWARDS ARROW
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
420 (#x2190 ?=) ;; U+2190 LEFTWARDS ARROW
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
421 (#x2191 ?=) ;; U+2191 UPWARDS ARROW
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
422 (#x2193 ?=) ;; U+2193 DOWNWARDS ARROW
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
423 (#x2229 ?=) ;; U+2229 INTERSECTION
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
424 (#x2202 ?=) ;; U+2202 PARTIAL DIFFERENTIAL
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
425 (#x2261 ?=) ;; U+2261 IDENTICAL TO
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
426 (#x221a ?=) ;; U+221A SQUARE ROOT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
427 (#x222b ?=) ;; U+222B INTEGRAL
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
428 (#x2030 ?=) ;; U+2030 PER MILLE SIGN
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
429 (#x266a ?=) ;; U+266A EIGHTH NOTE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
430 (#x2020 ?*) ;; U+2020 DAGGER
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
431 (#x2021 ?*) ;; U+2021 DOUBLE DAGGER
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
432 (#x2500 ?|) ;; U+2500 BOX DRAWINGS LIGHT HORIZONTAL
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
433 (#x2502 ?|) ;; U+2502 BOX DRAWINGS LIGHT VERTICAL
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
434 (#x250c ?|) ;; U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
435 (#x2510 ?|) ;; U+2510 BOX DRAWINGS LIGHT DOWN AND LEFT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
436 (#x2518 ?|) ;; U+2518 BOX DRAWINGS LIGHT UP AND LEFT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
437 (#x2514 ?|) ;; U+2514 BOX DRAWINGS LIGHT UP AND RIGHT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
438 (#x251c ?|) ;; U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
439 (#x252c ?|) ;; U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
440 (#x2524 ?|) ;; U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
441 (#x2534 ?|) ;; U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
442 (#x253c ?|) ;; U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
443 (#x02da ?^) ;; U+02DA RING ABOVE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
444 (#x2122 ?\xa9) ;; U+2122 TRADE MARK SIGN, ?,A)(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
445
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
446 (#x0132 ?\xe6) ;; U+0132 LATIN CAPITAL LIGATURE IJ, ?,Af(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
447 (#x013f ?\xe6) ;; U+013F LATIN CAPITAL LETTER L WITH MIDDLE DOT, ?,Af(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
448
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
449 (#x0133 ?\xe6) ;; U+0133 LATIN SMALL LIGATURE IJ, ?,Af(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
450 (#x0140 ?\xe6) ;; U+0140 LATIN SMALL LETTER L WITH MIDDLE DOT, ?,Af(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
451 (#x0149 ?\xe6) ;; U+0149 LATIN SMALL LETTER N PRECEDED BY APOSTROPH,?,Af(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
452
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
453 (#x2194 ?|) ;; U+2194 LEFT RIGHT ARROW
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
454 (#x2660 ?*) ;; U+2660 BLACK SPADE SUIT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
455 (#x2665 ?*) ;; U+2665 BLACK HEART SUIT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
456 (#x2663 ?*) ;; U+2663 BLACK CLUB SUIT
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
457 (#x2592 ?|) ;; U+2592 MEDIUM SHADE
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
458 (#x2195 ?|) ;; U+2195 UP DOWN ARROW
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
459
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
460 (#x2113 ?\xb9) ;; U+2113 SCRIPT SMALL L, ?,A9(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
461 (#x215b ?\xbe) ;; U+215B VULGAR FRACTION ONE EIGHTH, ?,A>(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
462 (#x215c ?\xbe) ;; U+215C VULGAR FRACTION THREE EIGHTHS, ?,A>(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
463 (#x215d ?\xbe) ;; U+215D VULGAR FRACTION FIVE EIGHTHS, ?,A>(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
464 (#x215e ?\xbe) ;; U+215E VULGAR FRACTION SEVEN EIGHTHS, ?,A>(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
465 (#x207f ?\xbe) ;; U+207F SUPERSCRIPT LATIN SMALL LETTER N, ?,A>(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
466
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
467 ;; These are not in WGL 4, but are IPA characters that should not
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
468 ;; be double width. They are the only IPA characters that both
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
469 ;; occur in packages/mule-packages/leim/ipa.el and end up in East
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
470 ;; Asian character sets when that file is loaded in an XEmacs
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
471 ;; without packages.
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
472 (#x2197 ?|) ;; U+2197 NORTH EAST ARROW
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
473 (#x2199 ?|) ;; U+2199 SOUTH WEST ARROW
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
474 (#x2191 ?|) ;; U+2191 UPWARDS ARROW
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
475 (#x207f ?\xb9));; U+207F SUPERSCRIPT LATIN SMALL LETTER N, ?,A9(B
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
476 with decoded = nil
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
477 with syntax-table = (standard-syntax-table)
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
478 ;; This creates jit-ucs-charset-0 entries because:
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
479 ;;
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
480 ;; 1. If the tables are dumped, it is run at dump time before they are
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
481 ;; dumped, and as such before the relevant conversions are available
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
482 ;; (they are made available in mule/general-late.el).
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
483 ;;
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
484 ;; 2. If the tables are not dumped, it is run at dump time, long before
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
485 ;; any of the other mappings are available.
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
486 ;;
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
487 do
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
488 (setq decoded (decode-char 'ucs ucs))
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
489 (assert (eq (char-charset decoded)
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
490 'jit-ucs-charset-0) nil
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
491 "Unexpected Unicode decoding behavior. ")
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
492 (modify-syntax-entry decoded
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
493 (string
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
494 (char-syntax ascii-or-latin-1))
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
495 syntax-table))
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
496
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
497 ;; Create all the Unicode error sequences, normally as jit-ucs-charset-0
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
498 ;; characters starting at U+200000 (which isn't a valid Unicode code
4202
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
499 ;; point). Make them available to user code.
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
500 (defvar unicode-error-default-translation-table
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
501 (loop
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
502 with char-table = (make-char-table 'char)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
503 for i from ?\x00 to ?\xFF
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
504 do
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
505 (put-char-table (aref
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
506 ;; #xd800 is the first leading surrogate;
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
507 ;; trailing surrogates must be in the range
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
508 ;; #xdc00-#xdfff. These examples are not, so we
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
509 ;; intentionally provoke an error sequence.
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
510 (decode-coding-string (format "\xd8\x00\x00%c" i)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
511 'utf-16-be)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
512 3)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
513 i
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
514 char-table)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
515 finally return char-table)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
516 "Translation table mapping Unicode error sequences to Latin-1 chars.
4145
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
517
4202
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
518 To transform XEmacs Unicode error sequences to the Latin-1 characters that
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
519 correspond to the octets on disk, you can use this variable. ")
4145
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
520
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
521 (defvar unicode-error-sequence-regexp-range
4202
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
522 (format "%c%c-%c"
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
523 (aref (decode-coding-string "\xd8\x00\x00\x00" 'utf-16-be) 0)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
524 (aref (decode-coding-string "\xd8\x00\x00\x00" 'utf-16-be) 3)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
525 (aref (decode-coding-string "\xd8\x00\x00\xFF" 'utf-16-be) 3))
4145
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
526 "Regular expression range to match Unicode error sequences in XEmacs.
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4096
diff changeset
527
4202
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
528 Invalid Unicode sequences on input are represented as XEmacs
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
529 characters with values stored as the keys in
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
530 `unicode-error-default-translation-table', one character for each
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
531 invalid octet. You can use this variable (with `re-search-forward' or
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
532 `skip-chars-forward') to search for such characters; see also
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
533 `unicode-error-translate-region'. ")
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
534
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
535 ;; Check that the lookup table is correct, and that all the actual error
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
536 ;; sequences are caught by the regexp.
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
537 (with-temp-buffer
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
538 (loop
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
539 for i from ?\x00 to ?\xFF
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
540 with to-check = (make-string 20 ?\x20)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
541 with res = t
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
542 do
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
543 (delete-region (point-min) (point-max))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
544 (insert to-check)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
545 (goto-char 10)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
546 (insert (decode-coding-string (format "\xd8\x00\x00%c" i)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
547 'utf-16-be))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
548 (backward-char)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
549 (assert (= i (get-char-table (char-after (point))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
550 unicode-error-default-translation-table))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
551 (format "Char ?\\x%x not the expected error sequence!"
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
552 i))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
553
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
554 (goto-char (point-min))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
555 (assert (re-search-forward (concat "["
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
556 unicode-error-sequence-regexp-range
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
557 "]"))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
558 nil
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
559 (format "Could not find char ?\\x%x in buffer" i))))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
560
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
561 (defun frob-unicode-errors-region (frob-function begin end &optional buffer)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
562 "Call FROB-FUNCTION on the Unicode error sequences between BEGIN and END.
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
563
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
564 Optional argument BUFFER specifies the buffer that should be examined for
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
565 such sequences. "
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
566 (check-argument-type #'functionp frob-function)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
567 (check-argument-range begin (point-min buffer) (point-max buffer))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
568 (check-argument-range end (point-min buffer) (point-max buffer))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
569 (save-excursion
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
570 (save-restriction
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
571 (if buffer (set-buffer buffer))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
572 (narrow-to-region begin end)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
573 (goto-char (point-min))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
574 (while end
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
575 (setq begin
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
576 (progn
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
577 (skip-chars-forward
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
578 (concat "^" unicode-error-sequence-regexp-range))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
579 (point))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
580 end (and (not (= (point) (point-max)))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
581 (progn
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
582 (skip-chars-forward
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
583 unicode-error-sequence-regexp-range)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
584 (point))))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
585 (if end
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
586 (funcall frob-function begin end))))))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
587
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
588 (defun unicode-error-translate-region (begin end &optional buffer table)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
589 "Translate the Unicode error sequences in BUFFER between BEGIN and END.
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
590
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
591 The error sequences are transformed, by default, into the ASCII,
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
592 control-1 and latin-iso8859-1 characters with the numeric values
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
593 corresponding to the incorrect octets encountered. This is achieved
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
594 by using `unicode-error-default-translation-table' (which see) for
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
595 TABLE; you can change this by supplying another character table,
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
596 mapping from the error sequences to the desired characters. "
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
597 (unless table (setq table unicode-error-default-translation-table))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
598 (frob-unicode-errors-region
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
599 (lambda (start finish)
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
600 (translate-region start finish table))
a7c5de5b9880 [xemacs-hg @ 2007-10-02 10:33:04 by aidan]
aidan
parents: 4145
diff changeset
601 begin end buffer)))
3667
4c8ad140bcec [xemacs-hg @ 2006-11-07 18:51:21 by aidan]
aidan
parents: 3666
diff changeset
602
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
603 ;; #### UTF-7 is not yet implemented, and it's tricky to do. There's
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
604 ;; an implementation in appendix A.1 of the Unicode Standard, Version
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
605 ;; 2.0, but I don't know its licensing characteristics.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
606
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
607 ; (make-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
608 ; 'utf-7 'unicode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
609 ; "UTF-7"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
610 ; '(mnemonic "UTF7"
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3506
diff changeset
611 ; documentation; "UTF-7 Unicode encoding -- 7-bit-ASCII modal Internet-mail-compatible
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
612 ; encoding especially designed for headers, with the following
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
613 ; properties:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
614
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
615 ; -- Only characters that are considered safe for passing through any mail
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
616 ; gateway without damage are used.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
617
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
618 ; -- This is a modal encoding, with two states. The first, default
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
619 ; state encodes the most common Unicode characters (upper and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
620 ; lowercase letters, digits, and 9 common punctuation marks) as
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
621 ; themselves, and the second state, entered using '+' and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
622 ; terminated with '-' or any character disallowed in state 2,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
623 ; encodes any Unicode characters by first converting to UTF-16,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
624 ; most significant byte first, and then to a slightly modified
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
625 ; Base64 encoding. (Thus, UTF-7 has the same limitations on the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
626 ; characters it can encode as UTF-16.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
627
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
628 ; -- The modified Base64 encoding deviates from standard Base64 in
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
629 ; that it omits the `=' pad character. This is eliminated so as to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
630 ; avoid conflicts with the use of `=' as an escape in the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
631 ; Quoted-Printable encoding and the related Q encoding for headers:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
632 ; With this modification, non-whitespace chars in UTF-7 will be
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
633 ; represented in Quoted-Printable and in Q as-is, with no further
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
634 ; encoding.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
635
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
636 ; For more information, see Appendix A.1 of The Unicode Standard 2.0, or
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents:
diff changeset
637 ; wherever it is in v3.0."
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3667
diff changeset
638 ; unicode-type utf-7))