TIVI-153: Add as dependency for iputils
[profile/ivi/opensp.git] / doc / charset.htm
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>OpenSP - Character sets</TITLE>
5 </HEAD>
6 <BODY>
7 <H1>Handling of character sets in OpenSP</H1>
8 <P>
9 The following description applies only to the multi-byte version of
10 OpenSP.  In the single-byte version of OpenSP, each character is represented
11 both internally and in storage objects by a single byte equal to the
12 number of the character in the document character set.
13 <P>
14 OpenSP's entity manager converts the bytes comprising a storage object
15 into a sequence of characters.
16 This conversion is determined by the encoding associated with
17 the storage object.
18 <P>
19 An encoding may be specified using the name of a mapping from
20 sequences of characters to sequences of bytes.
21 <P>
22 An encoding can also be specified relative to the document character
23 set.  This kind of an encoding maps a sequence of characters in the
24 repertoire of the document character set into a sequence of bytes by
25 <OL>
26 <LI>
27 mapping each character to its bit
28 combination in the document character set, and then
29 <LI>
30 applying a transformation that maps sequences of bit combinations
31 to sequences of bytes.
32 </OL>
33 <P>
34 The transformation applied in the second step is called a bit
35 combination transformation format (BCTF).
36 A document character set relative encoding is specified by giving
37 the name of a BCTF.
38 <P>
39 An application receives characters from OpenSP represented as non-negative
40 integers.
41 The mapping from characters to integers is determined by OpenSP's internal
42 character set.
43 OpenSP can operate in a mode in which the internal character set is the
44 same as the document character set.
45 (Versions of SP up to 1.1.1 always operated in this mode.)
46 <A NAME="fixed">
47 The multibyte version of OpenSP can also operate in a mode in which the
48 internal character set does not vary with the document character set,
49 but is always a fixed character set, known as the system character set;
50 this mode of operation is called fixed character set mode.</A>
51
52 <H2>Environment</H2>
53 <P>
54 SP's character set handling is controlled by the following
55 environment variables:
56 <DL>
57 <DT>
58 SP_CHARSET_FIXED
59 <DD>
60 If this variable is 1 or YES, then OpenSP will operate in fixed character set mode.
61 <DT>
62 SP_SYSTEM_CHARSET
63 <DD>
64 This identifies the system character set.  When in fixed character set
65 mode, this character set is used as the internal character set.  When
66 not in fixed character set mode this character set is used as the
67 internal character set until the document character set has been read,
68 at which point the document character set is used as the internal
69 character set.
70 <P>
71 The only currently recognized value for this is <SAMP>JIS</SAMP>.
72 This refers to a character set which combines JIS X 0201, JIS X 0208
73 and JIS X 0212 by adding 0x8080 to the codes of characters in JIS X
74 0208 and 0x8000 to the codes of characters in JIS X 0212.
75 <P>
76 The default system character set is Unicode 2.0.
77 <DT>
78 SP_ENCODING
79 <DD>
80 This specifies the default encoding when operating in fixed character set mode.
81 The value must be the name of an available encoding.
82 The default encoding cannot be document character set relative
83 when operating in fixed character set mode.
84 <DT>
85 SP_BCTF
86 <DD>
87 This specifies the default encoding when not operating in fixed character set mode.
88 The value must be the name of an available BCTF.
89 When not operating in fixed character set mode, the default encoding is
90 the document character set relative encoding with this BCTF.
91 The default encoding is required to be document character set relative
92 when not operating in fixed character set mode.
93 </DL>
94 <P>
95 The default encoding is used for file input and output, and, except
96 under Windows 95 and Windows NT, for all other interfaces with the
97 operating system including filenames, environment varable names,
98 environment variable values and command line arguments.
99 <P>
100 Under Windows 95 and Windows NT there are no restrictions on the
101 default encoding.  Note that in order for non-ASCII characters to be
102 correctly displayed on your console you must select a TrueType font,
103 such as Lucida Console, as your console font.  (This seems to work
104 only on Windows NT.)
105 <P>
106 Under other operating systems, the default encoding must be one in
107 which ASCII characters are represented by a single byte.
108 <P>
109 Applications built with OpenSP may require fixed character set mode and a
110 particular system character set; such applications will ignore the
111 SP_SYSTEM_CHARSET and SP_CHARSET_FIXED environment variables.
112
113 <H2><A NAME="encodings">Available encodings</A></H2>
114 <P>
115 Encoding names are case insensitive.
116 The following named encodings are available:
117 <DL>
118 <DT>
119 <SAMP>utf-8</SAMP>
120 <DD>
121 Each character is represented by a variable number of bytes
122 according to UCS Transformation Format 8 defined in Annex P to be
123 added by the first proposed drafted amendment (PDAM 1) to ISO/IEC
124 10646-1:1993.
125 <DT>
126 <SAMP>utf-16</SAMP>
127 <DD>
128 Each character is represented by a variable number of bytes
129 according to UCS Transformation Format 16 defined in Annex O to be
130 added by the first proposed drafted amendment (PDAM 1) to ISO/IEC
131 10646-1:1993.
132 <DT>
133 <SAMP>ucs-2</SAMP>
134 <DT>
135 <SAMP>iso-10646-ucs-2</SAMP>
136 <DD>
137 This is ISO/IEC 10646 with the UCS-2 transformation format.
138 Each character is represented by 2 bytes.
139 No special treatment is given to the byte order mark character.
140 <DT>
141 <SAMP>ucs-4</SAMP>
142 <DT>
143 <SAMP>iso-10646-ucs-4</SAMP>
144 <DT>
145 <SAMP>utf-32</SAMP>
146 <DD>
147 This is ISO/IEC 10646 with the UCS-4 transformation format.
148 Each character is represented by 4 bytes.
149 <DT>
150 <SAMP>unicode</SAMP>
151 <DD>
152 Each character is represented according to the utf-16 encoding.  
153 The bytes representing the entire storage object may be preceded by a pair of
154 bytes representing the byte order mark character (0xFEFF).  The bytes
155 representing each character are in the system byte order, unless
156 the byte order mark character is present, in which case the order of
157 its bytes determines the byte order.  When the storage object is read,
158 any byte order mark character is discarded.
159 <DT>
160 <SAMP>euc-jp</SAMP>
161 <DD>
162 This is equivalent to
163 the Extended_UNIX_Code_Packed_Format_for_Japanese Internet charset.
164 Each character is encoded by a variable length sequence of octets.
165 <DT>
166 <SAMP>euc-kr</SAMP>
167 <DD>
168 This is ASCII and KSC 5601 encoded with the EUC encoding
169 as defined by KS C 5861-1992.
170 <DT>
171 <SAMP>euc-cn</SAMP>
172 <DT>
173 <SAMP>cn-gb</SAMP>
174 <DT>
175 <SAMP>gb2312</SAMP>
176 <DD>
177 This is ASCII and GB 2312-80 encoded with the EUC encoding.
178 It is equivalent to the CN-GB MIME charset defined in RFC 1922.
179 <DT>
180 <SAMP>sjis</SAMP>
181 <DT>
182 <SAMP>shift_jis</SAMP>
183 <DD>
184 This is equivalent to the Shift_JIS Internet charset.
185 Each character is encoded by a variable length sequence of octets.
186 This is Microsoft's standard encoding for Japanese.
187 <DT>
188 <SAMP>big5</SAMP>
189 <DT>
190 <SAMP>cn-big5</SAMP>
191 <DD>
192 This is equivalent to the CN-Big5 MIME charset defined in RFC 1922.
193 <DT>
194 <SAMP>is8859-<VAR>n</VAR></SAMP>
195 <DT>
196 <SAMP>iso-8859-<VAR>n</VAR></SAMP>
197 <DD>
198 <SAMP><VAR>n</VAR></SAMP> can be any single digit other than 0.  Each
199 character in the repertoire of ISO 8859-<VAR>n</var> is represented
200 by a single byte.
201 <DT>
202 <SAMP>koi8-r</SAMP>
203 <DT>
204 <SAMP>koi8</SAMP>
205 <DD>
206 The koi8-r encoding as defined in RFC 1489.
207 <DT>
208 <SAMP>xml</SAMP>
209 <DD>
210 On input, this uses XML's rules to determine the encoding.
211 On output, this uses UTF-8.
212 </DL>
213 <P>
214 The following additional encodings are supported under Windows 95
215 and Windows NT:
216 <DL>
217 <DT>
218 <SAMP>windows</SAMP>
219 <DD>
220 Specify this encoding when a storage object is encoded using your
221 system's default Windows character set.
222 This uses the so-called ANSI code page.
223 <DT>
224 <SAMP>wunicode</SAMP>
225 <DD>
226 This uses the <SAMP>unicode</SAMP> encoding if the storage object starts
227 with a byte order mark and otherwise the <SAMP>windows</SAMP> encoding.
228 If you are working with Unicode, this is probably the best value
229 for <SAMP>SP_ENCODING</SAMP>.
230 <DT>
231 <SAMP>ms-dos</SAMP>
232 <DD>
233 Specify this encoding when a storage object (file) uses the OEM code page.
234 The OEM code-page for a particular
235 machine is the code-page used by FAT file-systems on that machine and
236 is the default code-page for MS-DOS consoles.
237 </DL>
238
239 <H2><A NAME="bctfs">Available BCTFs</A></H2>
240 <P>
241 The following BCTFs are available:
242 <DL>
243 <DT>
244 <SAMP>identity</SAMP>
245 <DD>
246 Each bit combination is represented by a single byte.
247 <DT>
248 <SAMP>fixed-2</SAMP>
249 <DD>
250 Each bit combination is represented by exactly 2 bytes,
251 with the more significant byte first.
252 <DT>
253 <SAMP>fixed-4</SAMP>
254 <DD>
255 Each bit combination is represented by exactly 4 bytes,
256 with the more significant byte first.
257 <DT>
258 <SAMP>utf-8</SAMP>
259 <DD>
260 Each bit combination is represented by a variable number of bytes
261 according to UCS Transformation Format 8 defined in Annex P to be
262 added by the first proposed drafted amendment (PDAM 1) to ISO/IEC
263 10646-1:1993.
264 <DT>
265 <SAMP>euc</SAMP>
266 <DD>
267 Each bit combination is represented by a variable number of bytes
268 depending on the values of the 0x80 and 0x8000 bits:
269 <UL>
270 <LI>
271 if neither bits are set, then the bit combination is
272 represented by a single byte equal to the bit combination;
273 <LI>
274 bit combinations with both bits set, are represented by the MSB of the
275 bit combination followed by the LSB of the bit combination;
276 <LI>
277 bit combinations with just the 0x80 bit set are represented
278 by 0x8E followed by a byte equal to the bit combination;
279 <LI>
280 bit combinations with just the 0x8000 bit set are represented
281 by 0x8F followed by the MSB of the bit combination followed
282 by the LSB of the bit combination.
283 </UL>
284 <DT>
285 <SAMP>sjis</SAMP>
286 <DD>
287 A bit combination between 0 and 127 or between 161 and
288 223 is encoded as a single byte with the same value as the bit combination.
289 A bit combination with the 0x8000 and 0x80 bits set is encoded by the
290 sequence of bytes with which the SJIS encoding encodes the character
291 whose number in JIS X 0208 added to 0x8080 is equal to the bit
292 combination.
293 <DT>
294 <SAMP>big5</SAMP>
295 <DD>
296 A bit combination less than 0x80 is encoded as a single byte.
297 A bit combination with the 0x8000 bit set is encoded as two bytes,
298 the MSB of the bit combination followed by the LSB of the bit
299 combination.
300 </DL>
301 </BODY>
302 </HTML>