/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/byteorder.h>
#include <sys/u8_textprep.h>
#include <sys/kiconv_cck_common.h>
#include <sys/kiconv_tc.h>
#include <sys/kiconv_big5_utf8.h>
#include <sys/kiconv_euctw_utf8.h>
#include <sys/kiconv_hkscs_utf8.h>
#include <sys/kiconv_cp950hkscs_utf8.h>
#include <sys/kiconv_utf8_big5.h>
#include <sys/kiconv_utf8_euctw.h>
#include <sys/kiconv_utf8_cp950hkscs.h>
#include <sys/kiconv_utf8_hkscs.h>
/* 4 HKSCS-2004 code points map to 2 Unicode code points separately. */
{ 0xc3, 0x8a, 0xcc, 0x84 }, /* 0x8862 */
{ 0xc3, 0x8a, 0xcc, 0x8c }, /* 0x8864 */
{ 0xc3, 0xaa, 0xcc, 0x84 }, /* 0x88a3 */
{ 0xc3, 0xaa, 0xcc, 0x8c } /* 0x88a5 */
};
/* 4 Unicode code point pair map to 1 HKSCS-2004 code point. */
0x8866, /* U+00ca */
0x8862, /* U+00ca U+0304 */
0x8864, /* U+00ca U+030c */
0x88a7, /* U+00ea */
0x88a3, /* U+00ea U+0304 */
0x88a5 /* U+00ea U+030c */
};
static void *
{
return ((void *)KICONV_TC_BIG5);
}
static void *
{
return ((void *)KICONV_TC_BIG5HKSCS);
}
static void *
{
return ((void *)KICONV_TC_CP950HKSCS);
}
static void *
{
return ((void *)KICONV_TC_EUCTW);
}
static int
close_fr_tc(void *s)
{
if ((uintptr_t)s > KICONV_TC_MAX_MAGIC_ID)
return (EBADF);
return (0);
}
/*
*/
static size_t
{
/* Check on the kiconv code conversion descriptor. */
return ((size_t)-1);
}
/* If this is a state reset request, process and return. */
return (0);
}
ret_val = 0;
if (KICONV_IS_ASCII(*ib)) {
}
continue;
}
/*
* Issue EILSEQ error if the first byte is not a
*/
if (! KICONV_TC_IS_BIG5_1st_BYTE(*ib)) {
}
/*
* Issue EINVAL error if input buffer has an incomplete
* character at the end of the buffer.
*/
}
/*
* Issue EILSEQ error if the remaining bytes is not
*/
}
if (sz < 0) {
}
ib += 2;
}
return (ret_val);
}
/*
* to UTF-8.
*/
static size_t
{
ret_val = 0;
break;
if (KICONV_IS_ASCII(*ib)) {
}
continue;
}
if (! KICONV_TC_IS_BIG5_1st_BYTE(*ib)) {
}
}
}
if (sz < 0) {
}
continue;
}
ret_val++;
}
return (ret_val);
}
/*
* Encoding convertor from BIG5 to UTF-8.
*/
static size_t
{
}
/*
* String based encoding convertor from BIG5 to UTF-8.
*/
static size_t
{
big5_to_utf8));
}
/*
* Encoding convertor from BIG5-HKSCS to UTF-8.
*/
static size_t
{
}
/*
* String based encoding convertor from BIG5-HKSCS to UTF-8.
*/
static size_t
{
}
/*
* Encoding convertor from CP950-HKSCS to UTF-8.
*/
static size_t
{
}
/*
* String based encoding convertor from CP950-HKSCS to UTF-8.
*/
static size_t
{
}
/*
* Encoding convertor from EUC-TW to UTF-8.
*/
static size_t
{
/* Check on the kiconv code conversion descriptor. */
return ((size_t)-1);
}
/* If this is a state reset request, process and return. */
return (0);
}
ret_val = 0;
if (KICONV_IS_ASCII(*ib)) {
}
continue;
}
/*
* Issue EILSEQ error if the first byte is not a
* valid EUC-TW leading byte.
*/
if (! KICONV_TC_IS_EUCTW_1st_BYTE(*ib)) {
}
/*
* Issue EINVAL error if input buffer has an incomplete
* character at the end of the buffer.
*/
}
/*
* Issue EILSEQ error if the remaining bytes are not
* valid EUC-TW bytes.
*/
if (! KICONV_TC_IS_VALID_EUCTW_SEQ(ib)) {
}
if (! isplane1)
ib += 2;
/* Now we have a valid EUC-TW character. */
if (sz < 0) {
}
}
return (ret_val);
}
/*
* String based encoding convertor from EUC-TW to UTF-8.
*/
static size_t
{
ret_val = 0;
break;
if (KICONV_IS_ASCII(*ib)) {
}
continue;
}
if (! KICONV_TC_IS_EUCTW_1st_BYTE(*ib)) {
}
if (flag & KICONV_REPLACE_INVALID) {
goto REPLACE_INVALID;
}
}
if (! KICONV_TC_IS_VALID_EUCTW_SEQ(ib)) {
}
if (! isplane1)
ib += 2;
if (sz < 0) {
}
continue;
}
ret_val++;
}
return (ret_val);
}
/*
* Encoding convertor from UTF-8 to BIG5.
*/
static size_t
{
}
/*
* String based encoding convertor from UTF-8 to BIG5.
*/
static size_t
{
}
/*
* Encoding convertor from UTF-8 to EUC-TW.
*/
static size_t
{
}
/*
* String based encoding convertor from UTF-8 to EUC-TW.
*/
static size_t
{
}
/*
* Encoding convertor from UTF-8 to CP950HKSCS.
*/
static size_t
{
}
/*
* String based encoding convertor from UTF-8 to CP950HKSCS.
*/
static size_t
{
}
/*
* Encoding convertor from UTF-8 to BIG5HKSCS(HKSCS-2004).
*/
static size_t
{
}
/*
* String based encoding convertor from UTF-8 to BIG5HKSCS(HKSCS-2004).
*/
static size_t
{
}
/*
* Common convertor from single BIG5/CP950-HKSCS character to UTF-8.
* Return: > 0 - Converted successfully
* = -1 - E2BIG
*/
static int8_t
{
return (-1);
}
if (index == 0)
(*ret_val)++; /* Non-identical conversion */
return (sz);
}
/*
* Convert single BIG5 character to UTF-8.
*/
static int8_t
{
}
/*
* Convert single CP950-HKSCS character to UTF-8.
*/
static int8_t
{
}
/*
* Calculate unicode value for some CNS planes which fall in Unicode
* UDA range.
*/
static uint32_t
{
/*
* CNS Plane 15 is pre-allocated, so need move Plane 16 to back 15
* to compute the Unicode value.
*/
if (plane_no == 16)
--plane_no;
/* 0xF0000 + (plane_no - 12) * 8836 + (b1 - 0xA1) * 94 + (b2 - 0xA1) */
}
/*
* Convert single EUC-TW character to UTF-8.
* Return: > 0 - Converted successfully
* = -1 - E2BIG
*/
static int8_t
{
switch (plane_no) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 12:
case 13:
case 14:
case 16:
/*
* As U+F0000 <= u32 <= U+F8A0F, so its UTF-8 sequence
* will occupy 4 bytes.
*/
udc[0] = 0xF3;
index = 1;
break;
case 15:
break;
default:
index = 0;
}
return (-1);
}
if (index == 0)
(*ret_val)++;
return (sz);
}
/*
* Convert single HKSCS character to UTF-8.
* Return: > 0 - Converted successfully
* = -1 - E2BIG
*/
static int8_t
{
/*
* Single HKSCS-2004 character may map to 2 Unicode
* code points.
*/
if (u8[0] == 0xFF) {
sz = 4;
} else {
}
return (-1);
}
if (index == 0)
(*ret_val)++; /* Non-identical conversion. */
return (sz);
}
/*
* Convert single UTF-8 character to EUC-TW.
* Return: > 0 - Converted successfully
* = -1 - E2BIG
*/
/* ARGSUSED */
static int8_t
{
if (utf8 >= KICONV_TC_UDA_UTF8_START &&
utf8 <= KICONV_TC_UDA_UTF8_END) {
/*
* Calculate EUC-TW code if utf8 is in Unicode
* Private Plane 15.
*/
/* CNS Plane 15 is pre-allocated, so place it into Plane 16. */
if (plane_no == 15)
plane_no = 16;
} else {
if (index == 0) {
return (-1);
}
(*ret_val)++;
return (1);
}
}
return (-1);
}
if (plane_no != 1) {
*ob++ = KICONV_TC_EUCTW_MBYTE;
}
}
/*
* Convert single UTF-8 character to BIG5-HKSCS
* Return: > 0 - Converted successfully
* = -1 - E2BIG
*/
static int8_t
{
/*
* There are 4 special code points in HKSCS-2004 which mapped
* to 2 UNICODE code points.
*/
/* Check the following 2 bytes. */
}
}
return (-1);
}
if (index == 0)
(*ret_val)++;
if (hkscslen > 1)
if (special_sequence) { /* Advance for special sequence */
(*inbuf) += 2;
}
return (hkscslen);
}
/*
* Common convertor for UTF-8 to BIG5/CP950-HKSCS.
* Return: > 0 - Converted successfully
* = -1 - E2BIG
*/
static int8_t
{
return (-1);
}
if (index == 0)
(*ret_val)++;
if (big5len > 1)
return (big5len);
}
/*
* Convert single UTF-8 character to BIG5.
*/
/* ARGSUSED */
static int8_t
{
}
/*
* Convert single UTF-8 character to CP950-HKSCS for Windows compatibility.
*/
/* ARGSUSED */
static int8_t
{
}
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
};
"kiconv_tc", /* module name */
sizeof (kiconv_tc_ops_tbl) / sizeof (kiconv_tc_ops_tbl[0]),
0,
NULL,
NULL,
0
};
"kiconv Traditional Chinese module 1.0",
};
(void *)&modlkiconv_tc,
};
int
_init(void)
{
int err;
if (err)
return (err);
}
int
_fini(void)
{
int err;
/*
* If this module is being used, then, we cannot remove the module.
* The following checking will catch pretty much all usual cases.
*
* Any remaining will be catached by the kiconv_unregister_module()
* during mod_remove() at below.
*/
return (EBUSY);
if (err)
return (err);
}
int
{
}