xref: /freebsd/lib/libc/locale/euc.5 (revision bdcbfde31e8e9b343f113a1956384bdf30d1ed62)
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.Dd September 9, 2019
32.Dt EUC 5
33.Os
34.Sh NAME
35.Nm euc
36.Nd EUC encoding of wide characters
37.Sh SYNOPSIS
38.Nm ENCODING
39.Qq EUC
40.Pp
41.Nm VARIABLE
42.Ar len1
43.Ar mask1
44.Ar len2
45.Ar mask2
46.Ar len3
47.Ar mask3
48.Ar len4
49.Ar mask4
50.Ar mask
51.Sh DESCRIPTION
52.\"The
53.\".Nm EUC
54.\"encoding is provided for compatibility with
55.\".Ux
56.\"based systems.
57.\"See
58.\".Xr localedef 1
59.\"for a complete description of the
60.\".Ev LC_CTYPE
61.\"source file format.
62.\".Pp
63.Nm EUC
64implements a system of 4 multibyte codesets.
65A multibyte character in the first codeset consists of
66.Ar len1
67bytes starting with a byte in the range of 0x00 to 0x7f.
68To allow use of
69.Tn ASCII ,
70.Ar len1
71is always 1.
72A multibyte character in the second codeset consists of
73.Ar len2
74bytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f.
75A multibyte character in the third codeset consists of
76.Ar len3
77bytes starting with the byte 0x8e.
78A multibyte character in the fourth codeset consists of
79.Ar len4
80bytes starting with the byte 0x8f.
81.Pp
82The
83.Vt wchar_t
84encoding of
85.Nm EUC
86multibyte characters is dependent on the
87.Ar len
88and
89.Ar mask
90arguments.
91First, the bytes are moved into a
92.Vt wchar_t
93as follows:
94.Bd -literal
95byte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1
96.Ed
97.Pp
98The result is then ANDed with
99.Ar ~mask
100and ORed with
101.Ar maskN .
102Codesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is
103first removed and the
104.Ar lenN
105argument is reduced by 1.
106.Pp
107For example, the
108.Li ja_JP.eucJP
109locale has the following
110.Va VARIABLE
111line:
112.Bd -literal
113VARIABLE	1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080
114.Ed
115.Pp
116Codeset 1 consists of the values 0x0000 - 0x007f.
117.Pp
118Codeset 2 consists of the values who have the bits 0x8080 set.
119.Pp
120Codeset 3 consists of the values 0x0080 - 0x00ff.
121.Pp
122Codeset 4 consists of the values 0x8000 - 0xff7f excluding the values
123which have the 0x0080 bit set.
124.Pp
125Notice that the global
126.Ar mask
127is set to 0x8080, this implies that from those 2 bits the codeset can
128be determined.
129.Sh SEE ALSO
130.Xr localedef 1 ,
131.Xr setlocale 3
132