1.\" Copyright (c) 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Paul Borman at Krystal Technologies. 6.\" 7.\" %sccs.include.redist.roff% 8.\" 9.\" @(#)euc.4 8.1 (Berkeley) 06/04/93 10.\" 11.Dd "" 12.Dt EUC 4 13.Os 14.Sh NAME 15.Nm EUC 16.Nd EUC encoding of runes 17.Sh SYNOPSIS 18\fBENCODING "EUC"\fP 19.br 20\fBVARIABLE \fP\fIlen1 mask1 len2 mask2 len3 mask3 len4 mask4 mask\fP 21.Sh DESCRIPTION 22The 23.Nm EUC 24encoding is provided for compatibility with 25.Ux 26based systems. 27See 28.Xr mklocale 1 29for a complete description of the 30.Ev LC_CTYPE 31source file format. 32.Pp 33.Nm EUC 34implements a system of 4 multibyte codesets. 35A multibyte character in the first codeset consists of 36.Ar len1 37bytes starting with a byte in the range of 0x00 to 0x7f. 38To allow use of ASCII, 39.Ar len1 40is always 1. 41A multibyte character in the second codeset consists of 42.Ar len2 43bytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f. 44A multibyte character in the third codeset consists of 45.Ar len3 46bytes starting with the byte 0x8e. 47A multibyte character in the fourth codeset consists of 48.Ar len4 49bytes starting with the byte 0x8f. 50.Pp 51The 52.Ev rune_t 53encoding of 54.Nm EUC 55multibyte characters is dependent on the 56.Ar len 57and 58.Ar mask 59arguments. 60First, the bytes are moved into a 61.Ev rune_t 62as follows: 63.Bd -literal 64byte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1 65.Ed 66.sp 67The result is then ANDed with 68.Ar ~mask 69and ORed with 70.Ar mask\fPN. 71Codesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is 72first removed and the 73.Ar len\fPN 74argument is reduced by 1. 75.sp 76For example, the Japanese locale has the following 77.Ev VARIABLE 78line: 79.Bd -literal 80VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 81.Ed 82.sp 83Codeset 1 consists of the values 0x0000 - 0x007f. 84.sp 85Codeset 2 consists of the values who have the bits 0x8080 set. 86.sp 87Codeset 3 consists of the values 0x0080 - 0x00ff. 88.sp 89Codeset 4 consists of the values 0x8000 - 0xff7f excluding the values 90which have the 0x0080 bit set. 91.sp 92Notice that the global 93.Ar mask 94is set to 0x8080, this implies that from those 2 bits the codeset can 95be determined. 96.Sh "EXAMPLE - Japanese Locale" 97This is a complete example of an 98.Ev LC_CTYPE 99source file for the Japanese locale 100.Bd -literal 101/* 102 * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets 103 */ 104 105ENCODING "EUC" 106 107/* JIS JIS JIS */ 108/* X201 X208 X201 */ 109/* 00-7f 84-fe */ 110 111VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 112 113/* 114 * Code Set 1 115 */ 116ALPHA 'A' - 'Z' 'a' - 'z' 117CONTROL 0x00 - 0x1f 0x7f 118DIGIT '0' - '9' 119GRAPH 0x21 - 0x7e 120LOWER 'a' - 'z' 121PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e 122SPACE 0x09 - 0x0d 0x20 123UPPER 'A' - 'Z' 124XDIGIT 'a' - 'f' 'A' - 'F' 125BLANK ' ' '\t' 126PRINT 0x20 - 0x7e 127 128MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' > 129MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' > 130TODIGIT < '0' - '9' : 0 > 131TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 > 132 133/* 134 * Code Set 2 135 */ 136 137SPACE 0xa1a1 138PHONOGRAM 0xa1bc 139SPECIAL 0xa1a2 - 0xa1fe 140PUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */ 141 142SPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea 143SPECIAL 0xa2f2 - 0xa2f9 0xa2fe 144 145DIGIT 0xa3b0 - 0xa3b9 146UPPER 0xa3c1 - 0xa3da /* Romaji */ 147LOWER 0xa3e1 - 0xa3fa /* Romaji */ 148MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */ 149MAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */ 150MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > 151MAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 > 152 153XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 154 155TODIGIT < 0xa3b0 - 0xa3b9 : 0 > 156TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 > 157 158PHONOGRAM 0xa4a1 - 0xa4f3 159PHONOGRAM 0xa5a1 - 0xa5f6 160 161UPPER 0xa6a1 - 0xa6b8 /* Greek */ 162LOWER 0xa6c1 - 0xa6d8 /* Greek */ 163MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 > 164MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 > 165 166UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */ 167LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */ 168MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 > 169MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 > 170 171SPECIAL 0xa8a1 - 0xa8c0 172 173IDEOGRAM 0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe 174IDEOGRAM 0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe 175IDEOGRAM 0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1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IDEOGRAM 0xefa1 - 0xeffe 0xf0a1 - 0xf0fe 0xf1a1 - 0xf1fe 195IDEOGRAM 0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe 0xf4a1 - 0xf4a4 196/* 197 * This is for Code Set 3, half-width kana 198 */ 199SPECIAL 0xa1 - 0xdf 200PHONOGRAM 0xa1 - 0xdf 201CONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe 202.Ed 203.Sh "SEE ALSO" 204.Xr mklocale 1 , 205.Xr setlocale 3 206