home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / doc / CTEXT / ctext.tbl.ms next >
Encoding:
Text File  |  1991-07-28  |  16.1 KB  |  425 lines

  1. .\" Use tbl and -ms
  2. .sp 8
  3. .ce 5
  4. \s+2\fBCompound Text Encoding\fP\s-2
  5. .sp 6p
  6. Version 1.1
  7. MIT X Consortium Standard
  8. X Version 11, Release 5
  9. Robert W. Scheifler
  10. .sp 2
  11. .LP
  12. Copyright \(co 1989 by the Massachusetts Institute of Technology
  13. .LP
  14. Permission to use, copy, modify, and distribute this documentation for any
  15. purpose and without fee is hereby granted, provided that the above copyright
  16. notice and this permission notice appear in all copies.  MIT makes no
  17. representations about the suitability for any purpose of the information in
  18. this document.  This documentation is provided ``as is'' without express or
  19. implied warranty.
  20. .sp 2
  21. .NH 1
  22. Overview
  23. .LP
  24. Compound Text is a format for multiple character set data, such as
  25. multi-lingual text.  The format is based on ISO
  26. standards for encoding and combining character sets.  Compound Text is intended
  27. to be used in three main contexts: inter-client communication using selections
  28. (as defined in the ICCCM); window properties (e.g. window manager hints as
  29. defined in the ICCCM); and resources (e.g. as defined in Xlib and the Xt
  30. Intrinsics).
  31. .LP
  32. Compound Text is intended as an external representation, or interchange format,
  33. not as an internal representation.  It is expected (but not required) that
  34. clients will convert Compound Text to some internal representation for
  35. processing and rendering, and convert from that internal representation to
  36. Compound Text when providing textual data to another client.
  37. .NH 1
  38. Values
  39. .LP
  40. The name of this encoding is ``COMPOUND_TEXT''.  When text values are used in
  41. the ICCCM-compliant selection mechanism or are stored as window properties in
  42. the server, the type used should be the atom for ``COMPOUND_TEXT''.
  43. .LP
  44. Octet values are represented in this document as two decimal numbers in the
  45. form col/row.  This means the value (col * 16) + row.  For example, 02/01 means
  46. the value 33.
  47. .LP
  48. For our purposes, the octet encoding space is divided into four ranges:
  49. .RS
  50. .TS
  51. l l.
  52. C0    octets from 00/00 to 01/15
  53. GL    octets from 02/00 to 07/15
  54. C1    octets from 08/00 to 09/15
  55. GR    octets from 10/00 to 15/15
  56. .TE
  57. .RE
  58. .LP
  59. C0 and C1 are ``control character'' sets, while GL and GR are ``graphic
  60. character'' sets.  Only a subset of C0 and C1 octets are used in the encoding,
  61. and depending on the character set encoding defined as GL or GR, a subset of
  62. GL and GR octets may be used; see below for details.  All octets (00/00 to
  63. 15/15) may appear inside the text of extended segments (defined below).
  64. .LP
  65. [For those familiar with ISO 2022, we will use only an 8-bit environment, and
  66. we will always use G0 for GL and G1 for GR.]
  67. .NH 1
  68. Control Characters
  69. .LP
  70. In C0, only the following values will be used:
  71. .RS
  72. .TS
  73. l l l.
  74. 00/09    HT    HORIZONTAL TABULATION
  75. 00/10    NL    NEW LINE
  76. 01/11    ESC    (ESCAPE)
  77. .TE
  78. .RE
  79. .LP
  80. In C1, only the following value will be used:
  81. .RS
  82. .TS
  83. l l l.
  84. 09/11    CSI    CONTROL SEQUENCE INTRODUCER
  85. .TE
  86. .RE
  87. .LP
  88. [The alternate 7-bit CSI encoding 01/11 05/11 is not used in Compound Text.]
  89. .LP
  90. No control sequences are defined in Compound Text for changing the C0 and C1
  91. sets.
  92. .LP
  93. A horizontal tab can be represented with the octet 00/09.  Specification of
  94. tabulation width settings is not part of Compound Text, and must be obtained
  95. from context (in an unspecified manner).
  96. .LP
  97. [Inclusion of horizontal tab is for consistency with the STRING type currently
  98. defined in the ICCCM.]
  99. .LP
  100. A newline (line separator/terminator) can be represented with the octet 00/10.
  101. .LP
  102. [Note that 00/10 is normally LINEFEED, but is being interpreted as NEWLINE.
  103. This can be thought of as using the (deprecated) NEW LINE mode, E.1.3, in ISO
  104. 6429.  Use of this value instead of 08/05 (NEL, NEXT LINE) is for consistency
  105. with the STRING type currently defined in the ICCCM.]
  106. .LP
  107. The remaining C0 and C1 values (01/11 and 09/11) are only used in the control
  108. sequences defined below.
  109. .NH 1
  110. Standard Character Set Encodings
  111. .LP
  112. The default GL and GR sets in Compound Text correspond to the left and right
  113. halves of ISO 8859-1 (Latin 1).  As such, any legal instance of a STRING type
  114. (as defined in the ICCCM) is also a legal instance of type COMPOUND_TEXT.
  115. .LP
  116. .nf
  117. [The implied initial state in ISO 2022 is defined with the sequence:
  118.  01/11 02/00 04/03  GO and G1 in an 8-bit environment only.  Designation also invokes.
  119.  01/11 02/00 04/07  In an 8-bit environment, C1 represented as 8-bits.
  120.  01/11 02/00 04/09  Graphic character sets can be 94 or 96.
  121.  01/11 02/00 04/11  8-bit code is used.
  122.  01/11 02/08 04/02  Designate ASCII into G0.
  123.  01/11 02/13 04/01  Designate right-hand part of ISO Latin-1 into G1.
  124. ]
  125. .fi
  126. .LP
  127. To define one of the approved standard character set encodings to be
  128. the GL set, one of the following control sequences is used:
  129. .RS
  130. .TS
  131. l l.
  132. 01/11 02/08 {I} F    94 character set
  133. 01/11 02/04 02/08 {I} F    94\u\s-2N\s+2\d character set
  134. .TE
  135. .RE
  136. .LP
  137. To define one of the approved standard character set encodings to be
  138. the GR set, one of the following control sequences is used:
  139. .RS
  140. .TS
  141. l l.
  142. 01/11 02/09 {I} F    94 character set
  143. 01/11 02/13 {I} F    96 character set
  144. 01/11 02/04 02/09 {I} F    94\u\s-2N\s+2\d character set
  145. .TE
  146. .RE
  147. .LP
  148. The ``F''in the control sequences above stands for ``Final character'', which
  149. is always in the range 04/00 to 07/14.  The ``{I}'' stands for zero or more
  150. ``intermediate characters'', which are always in the range 02/00 to 02/15, with
  151. the first intermediate character always in the range 02/01 to 02/03.  The
  152. registration authority has defined an ``{I} F'' sequence for each registered
  153. character set encoding.
  154. .LP
  155. [Final characters for private encodings (in the range 03/00 to 03/15, are not
  156. permitted here in Compound Text.]
  157. .LP
  158. For GL, octet 02/00 is always defined as SPACE, and octet 07/15 (normally
  159. DELETE) is never used.  For a 94-character set defined as GR, octets 10/00 and
  160. 15/15 are never used.
  161. .LP
  162. [This is consistent with ISO 2022.]
  163. .LP
  164. A 94\u\s-2N\s+2\d character set uses N octets (N>1) for each character.
  165. The value of N is derived from the column value for F:
  166. .RS
  167. .TS
  168. l l.
  169. column 04 or 05    2 octets
  170. column 06    3 octets
  171. column 07    4 or more octets
  172. .TE
  173. .RE
  174. .LP
  175. In a 94\u\s-2N\s+2\d encoding, the octet values 02/00 and 07/15 (in GL) and
  176. 10/00 and 15/15 (in GR) are never used.
  177. .LP
  178. [The column definitions come from ISO 2022.]
  179. .LP
  180. Once a GL or GR set has been defined, all further octets in that range (except
  181. within control sequences and extended segments) are interpreted with respect to
  182. that character set encoding, until the GL or GR set is redefined.  GL and GR
  183. sets can be defined independently, they do not have to be defined in pairs.
  184. .LP
  185. Note that when actually using a character set encoding as the GR set, you must
  186. force the most significant bit (08/00) of each octet to be a one, so that it
  187. falls in the range 10/00 to 15/15.
  188. .LP
  189. [Control sequences to specify character set encoding revisions (as in section
  190. 6.3.13 of ISO 2022) are not used in Compound Text.  Revision indicators do not
  191. appear to provide useful information in the context of Compound Text.  The most
  192. recent revision can always be assumed, since revisions are upward compatible.]
  193. .NH 1
  194. Approved Standard Encodings
  195. .LP
  196. The following are the approved standard encodings to be used with Compound
  197. Text.  Note that none have Intermediate characters; however, a good parser will
  198. still deal with Intermediate characters in the event that additional encodings
  199. are later added to this list.
  200. .RS
  201. .TS
  202. l l l.
  203. \fB{I} F\fP    \fB94/96\fP    \fBDescription\fP
  204. _
  205.  
  206. 04/02    94    7-bit ASCII graphics (ANSI X3.4-1968),
  207.         Left half of ISO 8859 sets
  208. 04/09    94    Right half of JIS X0201-1976 (reaffirmed 1984),
  209.         8-Bit Alphanumeric-Katakana Code
  210. 04/10    94    Left half of JIS X0201-1976 (reaffirmed 1984),
  211.         8-Bit Alphanumeric-Katakana Code
  212.  
  213. 04/01    96    Right half of ISO 8859-1, Latin alphabet No. 1
  214. 04/02    96    Right half of ISO 8859-2, Latin alphabet No. 2
  215. 04/03    96    Right half of ISO 8859-3, Latin alphabet No. 3
  216. 04/04    96    Right half of ISO 8859-4, Latin alphabet No. 4
  217. 04/06    96    Right half of ISO 8859-7, Latin/Greek alphabet
  218. 04/07    96    Right half of ISO 8859-6, Latin/Arabic alphabet
  219. 04/08    96    Right half of ISO 8859-8, Latin/Hebrew alphabet
  220. 04/12    96    Right half of ISO 8859-5, Latin/Cyrillic alphabet
  221. 04/13    96    Right half of ISO 8859-9, Latin alphabet No. 5
  222.  
  223. 04/01    94\u\s-22\s+2\d    GB2312-1980, China (PRC) Hanzi
  224. 04/02    94\u\s-22\s+2\d    JIS X0208-1983, Japanese Graphic Character Set
  225. 04/03    94\u\s-22\s+2\d    KS C5601-1987, Korean Graphic Character Set
  226. .TE
  227. .RE
  228. .LP
  229. The sets listed as ``Left half of ...'' should always be defined as GL.  The
  230. sets listed as ``Right half of ...'' should always be defined as GR.  Other
  231. sets can be defined either as GL or GR.
  232. .NH 1
  233. Non-Standard Character Set Encodings
  234. .LP
  235. Character set encodings that are not in the list of approved standard
  236. encodings can be included
  237. using ``extended segments''.  An extended segment begins with one of the
  238. following sequences:
  239. .RS
  240. .TS
  241. l l.
  242. 01/11 02/05 02/15 03/00 M L    variable number of octets per character
  243. 01/11 02/05 02/15 03/01 M L    1 octet per character
  244. 01/11 02/05 02/15 03/02 M L    2 octets per character
  245. 01/11 02/05 02/15 03/03 M L    3 octets per character
  246. 01/11 02/05 02/15 03/04 M L    4 octets per character
  247. .TE
  248. .RE
  249. [This uses the ``other coding system'' of ISO 2022, using private Final
  250. characters.]
  251. .LP
  252. The ``M'' and ``L'' octets represent a 14-bit unsigned value giving the number
  253. of octets that appear in the remainder of the segment.  The number is computed
  254. as ((M - 128) * 128) + (L - 128).  The most significant bit M and L are always
  255. set to one.  The remainder of the segment consists of two parts, the name of
  256. the character set encoding and the actual text.  The name of the encoding comes
  257. first, and is separated from the text by the octet 00/02 (STX, START OF TEXT).
  258. Note that the length defined by M and L includes the encoding name and
  259. separator.
  260. .LP
  261. [The encoding of the length is chosen to avoid having zero octets in Compound
  262. Text when possible, because embedded NUL values are problematic in many C
  263. language routines.  The use of zero octets cannot be ruled out entirely
  264. however, since some octets in the actual text of the extended segment may have
  265. to be zero.]
  266. .LP
  267. The name of the encoding should be registered with the X Consortium to avoid
  268. conflicts, and should when appropriate match the CharSet Registry and Encoding
  269. registration used in the X Logical Font Description.  The name itself should be
  270. encoded using ISO 8859-1 (Latin 1), should not use question mark (03/15) or
  271. asterisk (02/10), and should use hyphen (02/13) only in accordance with the X
  272. Logical Font Description.
  273. .LP
  274. Extended segments are not to be used for any character set encoding which can
  275. be constructed from a GL/GR pair of approved standard encodings. For
  276. example, it is incorrect to use an extended segment for any of the ISO 8859
  277. family of encodings.
  278. .LP
  279. It should be noted that the contents of an extended segment are arbitrary;
  280. e.g., they may contain octets in the C0 and C1 ranges, including 00/00, and
  281. octets comprising a given character may differ in their most significant bit.
  282. .LP
  283. [ISO registered ``other coding systems'' are not used in Compound Text;
  284. extended segments are the only mechanism for non-2022 encodings.]
  285. .NH 1
  286. Directionality
  287. .LP
  288. If desired, horizontal text direction can be indicated using the following
  289. control sequences:
  290. .RS
  291. .TS
  292. l l.
  293. 09/11 03/01 05/13    begin left-to-right text
  294. 09/11 03/02 05/13    begin right-to-left text
  295. 09/11 05/13    end of string
  296. .TE
  297. .RE
  298. .LP
  299. [This is a subset of the SDS (START DIRECTED STRING) control in the Draft
  300. Bidirectional Addendum to ISO 6429.]
  301. .LP
  302. Directionality can be nested.  Logically, a stack of directions is maintained.
  303. Each of the first two control sequences pushes a new direction on the stack,
  304. and the third sequence (revert) pops a direction from the stack.  The stack
  305. starts out empty at the beginning of a Compound Text string.  When the stack is
  306. empty, the directionality of the text is unspecified.
  307. .LP
  308. Directionality applies to all subsequent text, whether in GL, GR, or an
  309. extended segment.  If the desired directionality of GL, GR, or extended
  310. segments differ, then directionality control sequences must be inserted when
  311. switching between them.
  312. .LP
  313. Note that definition of GL and GR sets is independent of directionality;
  314. defining a new GL or GR set does not change the current directionality, and
  315. pushing or popping a directionality does not change the current GL and GR
  316. definitions.
  317. .LP
  318. Specification of directionality is entirely optional; text direction should be
  319. clear from context in most cases.  However, it must be the case that either
  320. all characters in a Compound Text string have explicitly specified direction,
  321. or that all characters have unspecified direction.  That is, if directionality
  322. control sequences are used, the first such control sequence must precede the
  323. first graphic character in a Compound Text string, and graphic characters are
  324. not permitted whenever the directionality stack is empty.
  325. .NH 1
  326. Resources
  327. .LP
  328. To use Compound Text in a resource, you can simply treat all octets as if they
  329. were ASCII/Latin-1, and just replace all ``\\'' octets (05/12) with the two
  330. octets ``\\\\'', all newline octets (00/10) with the two octets ``\\n'', and
  331. all zero octets with the four octets ``\\000''.
  332. It is up to the client making use of the resource to interpret the data as
  333. Compound Text; the policy by which this is ascertained is not constrained by
  334. the Compound Text specification.
  335. .NH 1
  336. Font Names
  337. .LP
  338. The following CharSet names for the standard character set encodings are
  339. registered for use in font names under the X Logical Font Description:
  340. .RS
  341. .TS
  342. l l.
  343. \fBName\fP    \fBEncoding Standard\fP
  344. _
  345.  
  346. ISO8859-1    ISO 8859-1
  347. ISO8859-2    ISO 8859-2
  348. ISO8859-3    ISO 8859-3
  349. ISO8859-4    ISO 8859-4
  350. ISO8859-5    ISO 8859-5
  351. ISO8859-6    ISO 8859-6
  352. ISO8859-7    ISO 8859-7
  353. ISO8859-8    ISO 8859-8
  354. ISO8859-9    ISO 8859-9
  355. JISX0201.1976-0    JIS X0201-1976 (reaffirmed 1984)
  356. GB2312.1980-0    GB2312-1980, GL encoding
  357. JISX0208.1983-0    JIS X0208-1983, GL encoding
  358. KSC5601.1987-0    KS C5601-1987, GL encoding
  359. .TE
  360. .RE
  361. .LP
  362. .NH 1
  363. Extensions
  364. .LP
  365. There is no absolute requirement for a parser to deal with anything but the
  366. particular encoding syntax defined in this specification.  However, it is
  367. possible that Compound Text may be extended in the future, and as such it may
  368. be desirable to construct the parser to handle 2022/6429 syntax more generally.
  369. .LP
  370. There are two general formats covering all control sequences that are expected
  371. to appear in extensions:
  372. .LP
  373. 01/11 {I} F
  374. .IP
  375. For this format, I is always in the range 02/00 to 02/15, and F is always
  376. in the range 03/00 to 07/14.
  377. .LP
  378. 09/11 {P} {I} F
  379. .IP
  380. For this format, P is always in the range 03/00 to 03/15, I is always in
  381. the range 02/00 to 02/15, and F is always in the range 04/00 to 07/14.
  382. .LP
  383. In addition, new (singleton) control characters (in the C0 and C1 ranges) might
  384. be defined in the future.
  385. .LP
  386. Finally, new kinds of ``segments'' might be defined in the future using syntax
  387. similar to extended segments:
  388. .LP
  389. 01/11 02/05 02/15 F M L
  390. .IP
  391. For this format, F is in the range 03/05 to 3/15.  M and L are as defined
  392. in extended segments.  Such a segment will always be followed by the number
  393. of octets defined by M and L.  These octets can have arbitrary values, and
  394. need not follow the internal structure defined for current extended
  395. segments.
  396. .LP
  397. If extensions to this specification are defined in the future, then any string
  398. incorporating instances of such extensions must start with one of the following
  399. control sequences:
  400. .RS
  401. .TS
  402. l l.
  403. 01/11 02/03 V 03/00    ignoring extensions is OK
  404. 01/11 02/03 V 03/01    ignoring extensions is not OK
  405. .TE
  406. .RE
  407. .LP
  408. In either case, V is in the range 02/00 to 02/15 and indicates the major
  409. version
  410. minus one of the specification being used.  These version control sequences are
  411. for use by clients that implement earlier versions, but have implemented a
  412. general parser.  The first control sequence indicates that it is acceptable to
  413. ignore all extension control sequences; no mandatory information will be lost
  414. in the process.  The second control sequence indicates that it is unacceptable
  415. to ignore any extension control sequences; mandatory information would be lost
  416. in the process.  In general, it will be up to the client generating the
  417. Compound Text to decide which control sequence to use.
  418. .NH 1
  419. Errors
  420. .LP
  421. If a Compound Text string does not match the specification here (e.g.  uses
  422. undefined control characters, or undefined control sequences, or incorrectly
  423. formatted extended segments), it is best to treat the entire string as invalid,
  424. except as indicated by a version control sequence.
  425.