annotate src/mule-coding.h @ 247:e70b3a057e12 r20-5b22

Import from CVS: tag r20-5b22
author cvs
date Mon, 13 Aug 2007 10:18:21 +0200
parents 1f0dabaa0855
children 83b3d10dcba9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1 /* Header for code conversion stuff
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
2 Copyright (C) 1991, 1995 Free Software Foundation, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5 This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
10 later version.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
15 for more details.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
22 /* Synched up with: Mule 2.3. Not in FSF. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
23
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
24 /* 91.10.09 written by K.Handa <handa@etl.go.jp> */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25 /* Rewritten by Ben Wing <wing@666.com>. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27 #ifndef _XEMACS_MULE_CODING_H_
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28 #define _XEMACS_MULE_CODING_H_
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
29
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
30 struct decoding_stream;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
31 struct encoding_stream;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
32
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
33 /* Coding system types. These go into the TYPE field of a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
34 struct Lisp_Coding_System. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
35
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
36 enum coding_system_type
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
37 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
38 CODESYS_AUTODETECT, /* Automatic conversion. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
39 CODESYS_SHIFT_JIS, /* Shift-JIS; Hankaku (half-width) KANA
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
40 is also supported. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
41 CODESYS_ISO2022, /* Any ISO2022-compliant coding system.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
42 Includes JIS, EUC, CTEXT */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
43 CODESYS_BIG5, /* BIG5 (used for Taiwanese). */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
44 CODESYS_CCL, /* Converter written in CCL. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
45 CODESYS_NO_CONVERSION /* "No conversion"; used for binary files.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
46 We use quotes because there really
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
47 is some conversion being applied,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
48 but it appears to the user as if
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
49 the text is read in without conversion. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
50 #ifdef DEBUG_XEMACS
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
51 ,CODESYS_INTERNAL /* Raw (internally-formatted) data. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
52 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
53 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
54
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
55 enum eol_type
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
56 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
57 EOL_AUTODETECT,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
58 EOL_LF,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
59 EOL_CRLF,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
60 EOL_CR
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
61 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
62
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 120
diff changeset
63 typedef struct charset_conversion_spec charset_conversion_spec;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
64 struct charset_conversion_spec
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
65 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
66 Lisp_Object from_charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
67 Lisp_Object to_charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
68 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
69
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 120
diff changeset
70 typedef struct
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
71 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 120
diff changeset
72 Dynarr_declare (charset_conversion_spec);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
73 } charset_conversion_spec_dynarr;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
74
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
75 struct Lisp_Coding_System
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
76 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
77 struct lcrecord_header header;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
79 /* Name and doc string of this coding system. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
80 Lisp_Object name, doc_string;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
82 /* This is the major type of the coding system -- one of Big5, ISO2022,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
83 Shift-JIS, etc. See the constants above. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
84 enum coding_system_type type;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
85
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
86 /* Mnemonic string displayed in the modeline when this coding
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87 system is active for a particular buffer. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
88 Lisp_Object mnemonic;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
90 Lisp_Object post_read_conversion, pre_write_conversion;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
91
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
92 enum eol_type eol_type;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
94 /* Subsidiary coding systems that specify a particular type of EOL
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
95 marking, rather than autodetecting it. These will only be non-nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96 if (eol_type == EOL_AUTODETECT). */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
97 Lisp_Object eol_lf, eol_crlf, eol_cr;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
99 struct
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
100 {
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
101 /* What are the charsets to be initially designated to G0, G1,
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
102 G2, G3? If t, no charset is initially designated. If nil,
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
103 no charset is initially designated and no charset is allowed
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
104 to be designated. */
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
105 Lisp_Object initial_charset[4];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
107 /* If true, a designation escape sequence needs to be sent on output
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
108 for the charset in G[0-3] before that charset is used. */
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
109 unsigned char force_charset_on_output[4];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
110
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
111 charset_conversion_spec_dynarr *input_conv;
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
112 charset_conversion_spec_dynarr *output_conv;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
114 unsigned int shoort :1; /* C makes you speak Dutch */
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
115 unsigned int no_ascii_eol :1;
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
116 unsigned int no_ascii_cntl :1;
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
117 unsigned int seven :1;
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
118 unsigned int lock_shift :1;
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
119 unsigned int no_iso6429 :1;
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
120 unsigned int escape_quoted :1;
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
121 } iso2022;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
122
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
123 struct
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
124 {
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
125 /* For a CCL coding system, these specify the CCL programs used for
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
126 decoding (input) and encoding (output). */
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
127 Lisp_Object decode, encode;
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
128 } ccl;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
129 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
130
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
131 DECLARE_LRECORD (coding_system, struct Lisp_Coding_System);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
132 #define XCODING_SYSTEM(x) XRECORD (x, coding_system, struct Lisp_Coding_System)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
133 #define XSETCODING_SYSTEM(x, p) XSETRECORD (x, p, coding_system)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
134 #define CODING_SYSTEMP(x) RECORDP (x, coding_system)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
135 #define GC_CODING_SYSTEMP(x) GC_RECORDP (x, coding_system)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
136 #define CHECK_CODING_SYSTEM(x) CHECK_RECORD (x, coding_system)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
137 #define CONCHECK_CODING_SYSTEM(x) CONCHECK_RECORD (x, coding_system)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
138
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
139 #define CODING_SYSTEM_NAME(codesys) ((codesys)->name)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
140 #define CODING_SYSTEM_DOC_STRING(codesys) ((codesys)->doc_string)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
141 #define CODING_SYSTEM_TYPE(codesys) ((codesys)->type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
142 #define CODING_SYSTEM_MNEMONIC(codesys) ((codesys)->mnemonic)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
143 #define CODING_SYSTEM_POST_READ_CONVERSION(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
144 ((codesys)->post_read_conversion)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
145 #define CODING_SYSTEM_PRE_WRITE_CONVERSION(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
146 ((codesys)->pre_write_conversion)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
147 #define CODING_SYSTEM_EOL_TYPE(codesys) ((codesys)->eol_type)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
148 #define CODING_SYSTEM_EOL_LF(codesys) ((codesys)->eol_lf)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
149 #define CODING_SYSTEM_EOL_CRLF(codesys) ((codesys)->eol_crlf)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
150 #define CODING_SYSTEM_EOL_CR(codesys) ((codesys)->eol_cr)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
151 #define CODING_SYSTEM_ISO2022_INITIAL_CHARSET(codesys, g) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
152 ((codesys)->iso2022.initial_charset[g])
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
153 #define CODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT(codesys, g) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
154 ((codesys)->iso2022.force_charset_on_output[g])
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
155 #define CODING_SYSTEM_ISO2022_SHORT(codesys) ((codesys)->iso2022.shoort)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
156 #define CODING_SYSTEM_ISO2022_NO_ASCII_EOL(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
157 ((codesys)->iso2022.no_ascii_eol)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
158 #define CODING_SYSTEM_ISO2022_NO_ASCII_CNTL(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
159 ((codesys)->iso2022.no_ascii_cntl)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
160 #define CODING_SYSTEM_ISO2022_SEVEN(codesys) ((codesys)->iso2022.seven)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
161 #define CODING_SYSTEM_ISO2022_LOCK_SHIFT(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
162 ((codesys)->iso2022.lock_shift)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
163 #define CODING_SYSTEM_ISO2022_NO_ISO6429(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
164 ((codesys)->iso2022.no_iso6429)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
165 #define CODING_SYSTEM_ISO2022_ESCAPE_QUOTED(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
166 ((codesys)->iso2022.escape_quoted)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
167 #define CODING_SYSTEM_CCL_DECODE(codesys) ((codesys)->ccl.decode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
168 #define CODING_SYSTEM_CCL_ENCODE(codesys) ((codesys)->ccl.encode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
169
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
170 #define XCODING_SYSTEM_NAME(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
171 CODING_SYSTEM_NAME (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
172 #define XCODING_SYSTEM_DOC_STRING(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
173 CODING_SYSTEM_DOC_STRING (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
174 #define XCODING_SYSTEM_TYPE(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
175 CODING_SYSTEM_TYPE (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
176 #define XCODING_SYSTEM_MNEMONIC(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
177 CODING_SYSTEM_MNEMONIC (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
178 #define XCODING_SYSTEM_POST_READ_CONVERSION(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
179 CODING_SYSTEM_POST_READ_CONVERSION (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
180 #define XCODING_SYSTEM_PRE_WRITE_CONVERSION(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
181 CODING_SYSTEM_PRE_WRITE_CONVERSION (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
182 #define XCODING_SYSTEM_EOL_TYPE(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
183 CODING_SYSTEM_EOL_TYPE (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
184 #define XCODING_SYSTEM_EOL_LF(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
185 CODING_SYSTEM_EOL_LF (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
186 #define XCODING_SYSTEM_EOL_CRLF(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
187 CODING_SYSTEM_EOL_CRLF (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
188 #define XCODING_SYSTEM_EOL_CR(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
189 CODING_SYSTEM_EOL_CR (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
190 #define XCODING_SYSTEM_ISO2022_INITIAL_CHARSET(codesys, g) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
191 CODING_SYSTEM_ISO2022_INITIAL_CHARSET (XCODING_SYSTEM (codesys), g)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
192 #define XCODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT(codesys, g) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
193 CODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT (XCODING_SYSTEM (codesys), g)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
194 #define XCODING_SYSTEM_ISO2022_SHORT(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
195 CODING_SYSTEM_ISO2022_SHORT (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
196 #define XCODING_SYSTEM_ISO2022_NO_ASCII_EOL(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
197 CODING_SYSTEM_ISO2022_NO_ASCII_EOL (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
198 #define XCODING_SYSTEM_ISO2022_NO_ASCII_CNTL(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
199 CODING_SYSTEM_ISO2022_NO_ASCII_CNTL (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
200 #define XCODING_SYSTEM_ISO2022_SEVEN(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
201 CODING_SYSTEM_ISO2022_SEVEN (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
202 #define XCODING_SYSTEM_ISO2022_LOCK_SHIFT(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
203 CODING_SYSTEM_ISO2022_LOCK_SHIFT (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
204 #define XCODING_SYSTEM_ISO2022_NO_ISO6429(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
205 CODING_SYSTEM_ISO2022_NO_ISO6429 (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
206 #define XCODING_SYSTEM_ISO2022_ESCAPE_QUOTED(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
207 CODING_SYSTEM_ISO2022_ESCAPE_QUOTED (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
208 #define XCODING_SYSTEM_CCL_DECODE(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
209 CODING_SYSTEM_CCL_DECODE (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
210 #define XCODING_SYSTEM_CCL_ENCODE(codesys) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
211 CODING_SYSTEM_CCL_ENCODE (XCODING_SYSTEM (codesys))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
212
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
213 extern Lisp_Object Qbuffer_file_coding_system, Qcoding_system_error;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
214
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
215 extern Lisp_Object Vkeyboard_coding_system;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
216 extern Lisp_Object Vterminal_coding_system;
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
217 extern Lisp_Object Vcoding_system_for_read;
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
218 extern Lisp_Object Vcoding_system_for_write;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
219 extern Lisp_Object Vpathname_coding_system;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
220
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
221 extern Lisp_Object Qescape_quoted;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
222
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
223 /* Flags indicating current state while converting code. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
224
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
225 /* Used by everyone. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
226
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
227 #define CODING_STATE_END (1 << 0) /* If set, this is the last chunk of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
228 data being processed. When this
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
229 is finished, output any necessary
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
230 terminating control characters,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
231 escape sequences, etc. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
232 #define CODING_STATE_CR (1 << 1) /* If set, we just saw a CR. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
233
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
234
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
235 /* Used by Big 5 on output. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
236
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
237 #define CODING_STATE_BIG5_1 (1 << 2) /* If set, we just encountered
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
238 LEADING_BYTE_BIG5_1. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
239 #define CODING_STATE_BIG5_2 (1 << 3) /* If set, we just encountered
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
240 LEADING_BYTE_BIG5_2. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
241
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
242
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
243 /* Used by ISO2022 on input and output. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
244
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
245 #define CODING_STATE_R2L (1 << 4) /* If set, the current
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
246 directionality is right-to-left.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
247 Otherwise, it's left-to-right. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
248
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
249
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
250 /* Used by ISO2022 on input. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
251
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
252 #define CODING_STATE_ESCAPE (1 << 5) /* If set, we're currently parsing
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
253 an escape sequence and the upper
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
254 16 bits should be looked at to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
255 indicate what partial escape
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
256 sequence we've seen so far.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
257 Otherwise, we're running
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
258 through actual text. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
259 #define CODING_STATE_SS2 (1 << 6) /* If set, G2 is invoked into GL, but
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
260 only for the next character. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
261 #define CODING_STATE_SS3 (1 << 7) /* If set, G3 is invoked into GL,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
262 but only for the next character.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
263 If both CODING_STATE_SS2 and
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
264 CODING_STATE_SS3 are set,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
265 CODING_STATE_SS2 overrides; but
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
266 this probably indicates an error
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
267 in the text encoding. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
268 #define CODING_STATE_COMPOSITE (1 << 8) /* If set, we're currently processing
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
269 a composite character (i.e. a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
270 character constructed by
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
271 overstriking two or more
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
272 characters). */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
273
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
274
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
275 /* CODING_STATE_ISO2022_LOCK is the mask of flags that remain on until
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
276 explicitly turned off when in the ISO2022 encoder/decoder. Other flags are
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
277 turned off at the end of processing each character or escape sequence. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
278 # define CODING_STATE_ISO2022_LOCK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
279 (CODING_STATE_END | CODING_STATE_COMPOSITE | CODING_STATE_R2L)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
280 #define CODING_STATE_BIG5_LOCK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
281 CODING_STATE_END
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
282
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
283 /* Flags indicating what we've seen so far when parsing an
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
284 ISO2022 escape sequence. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
285 enum iso_esc_flag
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
286 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
287 /* Partial sequences */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
288 ISO_ESC_NOTHING, /* Nothing has been seen. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
289 ISO_ESC, /* We've seen ESC. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
290 ISO_ESC_2_4, /* We've seen ESC $. This indicates
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
291 that we're designating a multi-byte, rather
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
292 than a single-byte, character set. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
293 ISO_ESC_2_8, /* We've seen ESC 0x28, i.e. ESC (.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
294 This means designate a 94-character
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
295 character set into G0. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
296 ISO_ESC_2_9, /* We've seen ESC 0x29 -- designate a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
297 94-character character set into G1. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
298 ISO_ESC_2_10, /* We've seen ESC 0x2A. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
299 ISO_ESC_2_11, /* We've seen ESC 0x2B. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
300 ISO_ESC_2_12, /* We've seen ESC 0x2C -- designate a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
301 96-character character set into G0.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
302 (This is not ISO2022-standard.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
303 The following 96-character
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
304 control sequences are standard,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
305 though.) */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
306 ISO_ESC_2_13, /* We've seen ESC 0x2D -- designate a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
307 96-character character set into G1.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
308 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
309 ISO_ESC_2_14, /* We've seen ESC 0x2E. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
310 ISO_ESC_2_15, /* We've seen ESC 0x2F. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
311 ISO_ESC_2_4_8, /* We've seen ESC $ 0x28 -- designate
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
312 a 94^N character set into G0. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
313 ISO_ESC_2_4_9, /* We've seen ESC $ 0x29. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
314 ISO_ESC_2_4_10, /* We've seen ESC $ 0x2A. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
315 ISO_ESC_2_4_11, /* We've seen ESC $ 0x2B. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
316 ISO_ESC_2_4_12, /* We've seen ESC $ 0x2C. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
317 ISO_ESC_2_4_13, /* We've seen ESC $ 0x2D. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
318 ISO_ESC_2_4_14, /* We've seen ESC $ 0x2E. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
319 ISO_ESC_2_4_15, /* We've seen ESC $ 0x2F. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
320 ISO_ESC_5_11, /* We've seen ESC [ or 0x9B. This
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
321 starts a directionality-control
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
322 sequence. The next character
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
323 must be 0, 1, 2, or ]. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
324 ISO_ESC_5_11_0, /* We've seen 0x9B 0. The next
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
325 character must be ]. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
326 ISO_ESC_5_11_1, /* We've seen 0x9B 1. The next
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
327 character must be ]. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
328 ISO_ESC_5_11_2, /* We've seen 0x9B 2. The next
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
329 character must be ]. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
330
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
331 /* Full sequences. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
332 ISO_ESC_START_COMPOSITE, /* Private usage for START COMPOSING */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
333 ISO_ESC_END_COMPOSITE, /* Private usage for END COMPOSING */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
334 ISO_ESC_SINGLE_SHIFT, /* We've seen a complete single-shift sequence. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
335 ISO_ESC_LOCKING_SHIFT,/* We've seen a complete locking-shift sequence. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
336 ISO_ESC_DESIGNATE, /* We've seen a complete designation sequence. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
337 ISO_ESC_DIRECTIONALITY,/* We've seen a complete ISO6429 directionality
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
338 sequence. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
339 ISO_ESC_LITERAL /* We've seen a literal character ala
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
340 escape-quoting. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
341 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
342
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
343 /* Macros to define code of control characters for ISO2022's functions. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
344 /* code */ /* function */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
345 #define ISO_CODE_LF 0x0A /* line-feed */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
346 #define ISO_CODE_CR 0x0D /* carriage-return */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
347 #define ISO_CODE_SO 0x0E /* shift-out */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
348 #define ISO_CODE_SI 0x0F /* shift-in */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
349 #define ISO_CODE_ESC 0x1B /* escape */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
350 #define ISO_CODE_DEL 0x7F /* delete */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
351 #define ISO_CODE_SS2 0x8E /* single-shift-2 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
352 #define ISO_CODE_SS3 0x8F /* single-shift-3 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
353 #define ISO_CODE_CSI 0x9B /* control-sequence-introduce */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
354
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
355 /* Macros to access an encoding stream or decoding stream */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
356
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
357 #define CODING_STREAM_DECOMPOSE(str, flags, ch) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
358 do { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
359 flags = (str)->flags; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
360 ch = (str)->ch; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
361 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
362
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
363 #define CODING_STREAM_COMPOSE(str, flags, ch) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
364 do { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
365 (str)->flags = flags; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
366 (str)->ch = ch; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
367 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
368
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
369
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
370 /* For detecting the encoding of text */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
371 enum coding_category_type
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
372 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
373 CODING_CATEGORY_SHIFT_JIS,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
374 CODING_CATEGORY_ISO_7, /* ISO2022 system using only seven-bit bytes,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
375 no locking shift */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
376 CODING_CATEGORY_ISO_8_DESIGNATE, /* ISO2022 system using eight-bit bytes,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
377 no locking shift, no single shift,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
378 using designation to switch charsets */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
379 CODING_CATEGORY_ISO_8_1, /* ISO2022 system using eight-bit bytes,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
380 no locking shift, no designation sequences,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
381 one-dimension characters in the upper half. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
382 CODING_CATEGORY_ISO_8_2, /* ISO2022 system using eight-bit bytes,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
383 no locking shift, no designation sequences,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
384 two-dimension characters in the upper half. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
385 CODING_CATEGORY_ISO_LOCK_SHIFT, /* ISO2022 system using locking shift */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
386 CODING_CATEGORY_BIG5,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
387 CODING_CATEGORY_NO_CONVERSION
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
388 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
389
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
390 #define CODING_CATEGORY_LAST CODING_CATEGORY_NO_CONVERSION
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
391
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
392 #define CODING_CATEGORY_SHIFT_JIS_MASK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
393 (1 << CODING_CATEGORY_SHIFT_JIS)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
394 #define CODING_CATEGORY_ISO_7_MASK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
395 (1 << CODING_CATEGORY_ISO_7)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
396 #define CODING_CATEGORY_ISO_8_DESIGNATE_MASK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
397 (1 << CODING_CATEGORY_ISO_8_DESIGNATE)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
398 #define CODING_CATEGORY_ISO_8_1_MASK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
399 (1 << CODING_CATEGORY_ISO_8_1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
400 #define CODING_CATEGORY_ISO_8_2_MASK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
401 (1 << CODING_CATEGORY_ISO_8_2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
402 #define CODING_CATEGORY_ISO_LOCK_SHIFT_MASK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
403 (1 << CODING_CATEGORY_ISO_LOCK_SHIFT)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
404 #define CODING_CATEGORY_BIG5_MASK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
405 (1 << CODING_CATEGORY_BIG5)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
406 #define CODING_CATEGORY_NO_CONVERSION_MASK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
407 (1 << CODING_CATEGORY_NO_CONVERSION)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
408 #define CODING_CATEGORY_NOT_FINISHED_MASK \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
409 (1 << 30)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
410
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
411 /* Convert shift-JIS code (sj1, sj2) into internal string
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
412 representation (c1, c2). (The leading byte is assumed.) */
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
413
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
414 #define DECODE_SJIS(sj1, sj2, c1, c2) \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
415 do { \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
416 int I1 = sj1, I2 = sj2; \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
417 if (I2 >= 0x9f) \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
418 c1 = (I1 << 1) - ((I1 >= 0xe0) ? 0xe0 : 0x60), \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
419 c2 = I2 + 2; \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
420 else \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
421 c1 = (I1 << 1) - ((I1 >= 0xe0) ? 0xe1 : 0x61), \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
422 c2 = I2 + ((I2 >= 0x7f) ? 0x60 : 0x61); \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
423 } while (0)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 187
diff changeset
424
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
425 /* Convert the internal string representation of a Shift-JIS character
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
426 (c1, c2) into Shift-JIS code (sj1, sj2). The leading byte is
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
427 assumed. */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 187
diff changeset
428
215
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
429 #define ENCODE_SJIS(c1, c2, sj1, sj2) \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
430 do { \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
431 int I1 = c1, I2 = c2; \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
432 if (I1 & 1) \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
433 sj1 = (I1 >> 1) + ((I1 < 0xdf) ? 0x31 : 0x71), \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
434 sj2 = I2 - ((I2 >= 0xe0) ? 0x60 : 0x61); \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
435 else \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
436 sj1 = (I1 >> 1) + ((I1 < 0xdf) ? 0x30 : 0x70), \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
437 sj2 = I2 - 2; \
1f0dabaa0855 Import from CVS: tag r20-4b6
cvs
parents: 213
diff changeset
438 } while (0)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 187
diff changeset
439
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
440 extern Lisp_Object make_decoding_input_stream (Lstream *stream,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
441 Lisp_Object codesys);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
442 extern Lisp_Object make_encoding_input_stream (Lstream *stream,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
443 Lisp_Object codesys);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
444 extern Lisp_Object make_decoding_output_stream (Lstream *stream,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
445 Lisp_Object codesys);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
446 extern Lisp_Object make_encoding_output_stream (Lstream *stream,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
447 Lisp_Object codesys);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
448 extern Lisp_Object decoding_stream_coding_system (Lstream *stream);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
449 extern Lisp_Object encoding_stream_coding_system (Lstream *stream);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
450 extern void set_decoding_stream_coding_system (Lstream *stream,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
451 Lisp_Object codesys);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
452 extern void set_encoding_stream_coding_system (Lstream *stream,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
453 Lisp_Object codesys);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
454 #endif /* _XEMACS_MULE_CODING_H_ */