]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/locale/euc.5
nvi: import version 2.2.1
[FreeBSD/FreeBSD.git] / lib / libc / locale / euc.5
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 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. Neither the name of the University nor the names of its contributors
16 .\"    may be used to endorse or promote products derived from this software
17 .\"    without specific prior written permission.
18 .\"
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 .\" SUCH DAMAGE.
30 .\"
31 .\"     @(#)euc.4       8.1 (Berkeley) 6/4/93
32 .\"
33 .Dd September 9, 2019
34 .Dt EUC 5
35 .Os
36 .Sh NAME
37 .Nm euc
38 .Nd EUC encoding of wide characters
39 .Sh SYNOPSIS
40 .Nm ENCODING
41 .Qq EUC
42 .Pp
43 .Nm VARIABLE
44 .Ar len1
45 .Ar mask1
46 .Ar len2
47 .Ar mask2
48 .Ar len3
49 .Ar mask3
50 .Ar len4
51 .Ar mask4
52 .Ar mask
53 .Sh DESCRIPTION
54 .\"The
55 .\".Nm EUC
56 .\"encoding is provided for compatibility with
57 .\".Ux
58 .\"based systems.
59 .\"See
60 .\".Xr localedef 1
61 .\"for a complete description of the
62 .\".Ev LC_CTYPE
63 .\"source file format.
64 .\".Pp
65 .Nm EUC
66 implements a system of 4 multibyte codesets.
67 A multibyte character in the first codeset consists of
68 .Ar len1
69 bytes starting with a byte in the range of 0x00 to 0x7f.
70 To allow use of
71 .Tn ASCII ,
72 .Ar len1
73 is always 1.
74 A multibyte character in the second codeset consists of
75 .Ar len2
76 bytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f.
77 A multibyte character in the third codeset consists of
78 .Ar len3
79 bytes starting with the byte 0x8e.
80 A multibyte character in the fourth codeset consists of
81 .Ar len4
82 bytes starting with the byte 0x8f.
83 .Pp
84 The
85 .Vt wchar_t
86 encoding of
87 .Nm EUC
88 multibyte characters is dependent on the
89 .Ar len
90 and
91 .Ar mask
92 arguments.
93 First, the bytes are moved into a
94 .Vt wchar_t
95 as follows:
96 .Bd -literal
97 byte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1
98 .Ed
99 .Pp
100 The result is then ANDed with
101 .Ar ~mask
102 and ORed with
103 .Ar maskN .
104 Codesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is
105 first removed and the
106 .Ar lenN
107 argument is reduced by 1.
108 .Pp
109 For example, the
110 .Li ja_JP.eucJP
111 locale has the following
112 .Va VARIABLE
113 line:
114 .Bd -literal
115 VARIABLE        1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080
116 .Ed
117 .Pp
118 Codeset 1 consists of the values 0x0000 - 0x007f.
119 .Pp
120 Codeset 2 consists of the values who have the bits 0x8080 set.
121 .Pp
122 Codeset 3 consists of the values 0x0080 - 0x00ff.
123 .Pp
124 Codeset 4 consists of the values 0x8000 - 0xff7f excluding the values
125 which have the 0x0080 bit set.
126 .Pp
127 Notice that the global
128 .Ar mask
129 is set to 0x8080, this implies that from those 2 bits the codeset can
130 be determined.
131 .Sh SEE ALSO
132 .Xr localedef 1 ,
133 .Xr setlocale 3