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