1*a626204dSbostic.\" Copyright (c) 1993 2*a626204dSbostic.\" The Regents of the University of California. All rights reserved. 3bdd7e493Sbostic.\" 4bdd7e493Sbostic.\" This code is derived from software contributed to Berkeley by 5bdd7e493Sbostic.\" Paul Borman at Krystal Technologies. 6bdd7e493Sbostic.\" 7bdd7e493Sbostic.\" %sccs.include.redist.roff% 8bdd7e493Sbostic.\" 9*a626204dSbostic.\" @(#)euc.4 8.1 (Berkeley) 06/04/93 10bdd7e493Sbostic.\" 11bdd7e493Sbostic.Dd "" 12bdd7e493Sbostic.Dt EUC 4 13bdd7e493Sbostic.Os 14bdd7e493Sbostic.Sh NAME 15bdd7e493Sbostic.Nm EUC 16bdd7e493Sbostic.Nd EUC encoding of runes 17bdd7e493Sbostic.Sh SYNOPSIS 18bdd7e493Sbostic\fBENCODING "EUC"\fP 19bdd7e493Sbostic.br 20bdd7e493Sbostic\fBVARIABLE \fP\fIlen1 mask1 len2 mask2 len3 mask3 len4 mask4 mask\fP 21bdd7e493Sbostic.Sh DESCRIPTION 22bdd7e493SbosticThe 23bdd7e493Sbostic.Nm EUC 24bdd7e493Sbosticencoding is provided for compatibility with 25bdd7e493Sbostic.Ux 26bdd7e493Sbosticbased systems. 27bdd7e493SbosticSee 28bdd7e493Sbostic.Xr mklocale 1 29bdd7e493Sbosticfor a complete description of the 30bdd7e493Sbostic.Ev LC_CTYPE 31bdd7e493Sbosticsource file format. 32bdd7e493Sbostic.Pp 33bdd7e493Sbostic.Nm EUC 34bdd7e493Sbosticimplements a system of 4 multibyte codesets. 35bdd7e493SbosticA multibyte character in the first codeset consists of 36bdd7e493Sbostic.Ar len1 37bdd7e493Sbosticbytes starting with a byte in the range of 0x00 to 0x7f. 38bdd7e493SbosticTo allow use of ASCII, 39bdd7e493Sbostic.Ar len1 40bdd7e493Sbosticis always 1. 41bdd7e493SbosticA multibyte character in the second codeset consists of 42bdd7e493Sbostic.Ar len2 43bdd7e493Sbosticbytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f. 44bdd7e493SbosticA multibyte character in the third codeset consists of 45bdd7e493Sbostic.Ar len3 46bdd7e493Sbosticbytes starting with the byte 0x8e. 47bdd7e493SbosticA multibyte character in the fourth codeset consists of 48bdd7e493Sbostic.Ar len4 49bdd7e493Sbosticbytes starting with the byte 0x8f. 50bdd7e493Sbostic.Pp 51bdd7e493SbosticThe 52bdd7e493Sbostic.Ev rune_t 53bdd7e493Sbosticencoding of 54bdd7e493Sbostic.Nm EUC 55bdd7e493Sbosticmultibyte characters is dependent on the 56bdd7e493Sbostic.Ar len 57bdd7e493Sbosticand 58bdd7e493Sbostic.Ar mask 59bdd7e493Sbosticarguments. 60bdd7e493SbosticFirst, the bytes are moved into a 61bdd7e493Sbostic.Ev rune_t 62bdd7e493Sbosticas follows: 63bdd7e493Sbostic.Bd -literal 64bdd7e493Sbosticbyte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1 65bdd7e493Sbostic.Ed 66bdd7e493Sbostic.sp 67bdd7e493SbosticThe result is then ANDed with 68bdd7e493Sbostic.Ar ~mask 69bdd7e493Sbosticand ORed with 70bdd7e493Sbostic.Ar mask\fPN. 71bdd7e493SbosticCodesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is 72bdd7e493Sbosticfirst removed and the 73bdd7e493Sbostic.Ar len\fPN 74bdd7e493Sbosticargument is reduced by 1. 75bdd7e493Sbostic.sp 76bdd7e493SbosticFor example, the Japanese locale has the following 77bdd7e493Sbostic.Ev VARIABLE 78bdd7e493Sbosticline: 79bdd7e493Sbostic.Bd -literal 80bdd7e493SbosticVARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 81bdd7e493Sbostic.Ed 82bdd7e493Sbostic.sp 83bdd7e493SbosticCodeset 1 consists of the values 0x0000 - 0x007f. 84bdd7e493Sbostic.sp 85bdd7e493SbosticCodeset 2 consists of the values who have the bits 0x8080 set. 86bdd7e493Sbostic.sp 87bdd7e493SbosticCodeset 3 consists of the values 0x0080 - 0x00ff. 88bdd7e493Sbostic.sp 89bdd7e493SbosticCodeset 4 consists of the values 0x8000 - 0xff7f excluding the values 90bdd7e493Sbosticwhich have the 0x0080 bit set. 91bdd7e493Sbostic.sp 92bdd7e493SbosticNotice that the global 93bdd7e493Sbostic.Ar mask 94bdd7e493Sbosticis set to 0x8080, this implies that from those 2 bits the codeset can 95bdd7e493Sbosticbe determined. 96bdd7e493Sbostic.Sh "EXAMPLE - Japanese Locale" 97bdd7e493SbosticThis is a complete example of an 98bdd7e493Sbostic.Ev LC_CTYPE 99bdd7e493Sbosticsource file for the Japanese locale 100bdd7e493Sbostic.Bd -literal 101bdd7e493Sbostic/* 102bdd7e493Sbostic * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets 103bdd7e493Sbostic */ 104bdd7e493Sbostic 105bdd7e493SbosticENCODING "EUC" 106bdd7e493Sbostic 107bdd7e493Sbostic/* JIS JIS JIS */ 108bdd7e493Sbostic/* X201 X208 X201 */ 109bdd7e493Sbostic/* 00-7f 84-fe */ 110bdd7e493Sbostic 111bdd7e493SbosticVARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 112bdd7e493Sbostic 113bdd7e493Sbostic/* 114bdd7e493Sbostic * Code Set 1 115bdd7e493Sbostic */ 116bdd7e493SbosticALPHA 'A' - 'Z' 'a' - 'z' 117bdd7e493SbosticCONTROL 0x00 - 0x1f 0x7f 118bdd7e493SbosticDIGIT '0' - '9' 119bdd7e493SbosticGRAPH 0x21 - 0x7e 120bdd7e493SbosticLOWER 'a' - 'z' 121bdd7e493SbosticPUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e 122bdd7e493SbosticSPACE 0x09 - 0x0d 0x20 123bdd7e493SbosticUPPER 'A' - 'Z' 124bdd7e493SbosticXDIGIT 'a' - 'f' 'A' - 'F' 125bdd7e493SbosticBLANK ' ' '\t' 126bdd7e493SbosticPRINT 0x20 - 0x7e 127bdd7e493Sbostic 128bdd7e493SbosticMAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' > 129bdd7e493SbosticMAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' > 130bdd7e493SbosticTODIGIT < '0' - '9' : 0 > 131bdd7e493SbosticTODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 > 132bdd7e493Sbostic 133bdd7e493Sbostic/* 134bdd7e493Sbostic * Code Set 2 135bdd7e493Sbostic */ 136bdd7e493Sbostic 137bdd7e493SbosticSPACE 0xa1a1 138bdd7e493SbosticPHONOGRAM 0xa1bc 139bdd7e493SbosticSPECIAL 0xa1a2 - 0xa1fe 140bdd7e493SbosticPUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */ 141bdd7e493Sbostic 142bdd7e493SbosticSPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea 143bdd7e493SbosticSPECIAL 0xa2f2 - 0xa2f9 0xa2fe 144bdd7e493Sbostic 145bdd7e493SbosticDIGIT 0xa3b0 - 0xa3b9 146bdd7e493SbosticUPPER 0xa3c1 - 0xa3da /* Romaji */ 147bdd7e493SbosticLOWER 0xa3e1 - 0xa3fa /* Romaji */ 148bdd7e493SbosticMAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */ 149bdd7e493SbosticMAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */ 150bdd7e493SbosticMAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > 151bdd7e493SbosticMAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 > 152bdd7e493Sbostic 153bdd7e493SbosticXDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 154bdd7e493Sbostic 155bdd7e493SbosticTODIGIT < 0xa3b0 - 0xa3b9 : 0 > 156bdd7e493SbosticTODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 > 157bdd7e493Sbostic 158bdd7e493SbosticPHONOGRAM 0xa4a1 - 0xa4f3 159bdd7e493SbosticPHONOGRAM 0xa5a1 - 0xa5f6 160bdd7e493Sbostic 161bdd7e493SbosticUPPER 0xa6a1 - 0xa6b8 /* Greek */ 162bdd7e493SbosticLOWER 0xa6c1 - 0xa6d8 /* Greek */ 163bdd7e493SbosticMAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 > 164bdd7e493SbosticMAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 > 165bdd7e493Sbostic 166bdd7e493SbosticUPPER 0xa7a1 - 0xa7c1 /* Cyrillic */ 167bdd7e493SbosticLOWER 0xa7d1 - 0xa7f1 /* Cyrillic */ 168bdd7e493SbosticMAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 > 169bdd7e493SbosticMAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 > 170bdd7e493Sbostic 171bdd7e493SbosticSPECIAL 0xa8a1 - 0xa8c0 172bdd7e493Sbostic 173bdd7e493SbosticIDEOGRAM 0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe 174bdd7e493SbosticIDEOGRAM 0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe 175bdd7e493SbosticIDEOGRAM 0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1 - 0xb8fe 176bdd7e493SbosticIDEOGRAM 0xb9a1 - 0xb9fe 0xbaa1 - 0xbafe 0xbba1 - 0xbbfe 177bdd7e493SbosticIDEOGRAM 0xbca1 - 0xbcfe 0xbda1 - 0xbdfe 0xbea1 - 0xbefe 178bdd7e493SbosticIDEOGRAM 0xbfa1 - 0xbffe 0xc0a1 - 0xc0fe 0xc1a1 - 0xc1fe 179bdd7e493SbosticIDEOGRAM 0xc2a1 - 0xc2fe 0xc3a1 - 0xc3fe 0xc4a1 - 0xc4fe 180bdd7e493SbosticIDEOGRAM 0xc5a1 - 0xc5fe 0xc6a1 - 0xc6fe 0xc7a1 - 0xc7fe 181bdd7e493SbosticIDEOGRAM 0xc8a1 - 0xc8fe 0xc9a1 - 0xc9fe 0xcaa1 - 0xcafe 182bdd7e493SbosticIDEOGRAM 0xcba1 - 0xcbfe 0xcca1 - 0xccfe 0xcda1 - 0xcdfe 183bdd7e493SbosticIDEOGRAM 0xcea1 - 0xcefe 0xcfa1 - 0xcfd3 0xd0a1 - 0xd0fe 184bdd7e493SbosticIDEOGRAM 0xd1a1 - 0xd1fe 0xd2a1 - 0xd2fe 0xd3a1 - 0xd3fe 185bdd7e493SbosticIDEOGRAM 0xd4a1 - 0xd4fe 0xd5a1 - 0xd5fe 0xd6a1 - 0xd6fe 186bdd7e493SbosticIDEOGRAM 0xd7a1 - 0xd7fe 0xd8a1 - 0xd8fe 0xd9a1 - 0xd9fe 187bdd7e493SbosticIDEOGRAM 0xdaa1 - 0xdafe 0xdba1 - 0xdbfe 0xdca1 - 0xdcfe 188bdd7e493SbosticIDEOGRAM 0xdda1 - 0xddfe 0xdea1 - 0xdefe 0xdfa1 - 0xdffe 189bdd7e493SbosticIDEOGRAM 0xe0a1 - 0xe0fe 0xe1a1 - 0xe1fe 0xe2a1 - 0xe2fe 190bdd7e493SbosticIDEOGRAM 0xe3a1 - 0xe3fe 0xe4a1 - 0xe4fe 0xe5a1 - 0xe5fe 191bdd7e493SbosticIDEOGRAM 0xe6a1 - 0xe6fe 0xe7a1 - 0xe7fe 0xe8a1 - 0xe8fe 192bdd7e493SbosticIDEOGRAM 0xe9a1 - 0xe9fe 0xeaa1 - 0xeafe 0xeba1 - 0xebfe 193bdd7e493SbosticIDEOGRAM 0xeca1 - 0xecfe 0xeda1 - 0xedfe 0xeea1 - 0xeefe 194bdd7e493SbosticIDEOGRAM 0xefa1 - 0xeffe 0xf0a1 - 0xf0fe 0xf1a1 - 0xf1fe 195bdd7e493SbosticIDEOGRAM 0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe 0xf4a1 - 0xf4a4 196bdd7e493Sbostic/* 197bdd7e493Sbostic * This is for Code Set 3, half-width kana 198bdd7e493Sbostic */ 199bdd7e493SbosticSPECIAL 0xa1 - 0xdf 200bdd7e493SbosticPHONOGRAM 0xa1 - 0xdf 201bdd7e493SbosticCONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe 202bdd7e493Sbostic.Ed 203bdd7e493Sbostic.Sh "SEE ALSO" 204bdd7e493Sbostic.Xr mklocale 1 , 205bdd7e493Sbostic.Xr setlocale 3 206