8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 06:43:03 +01:00
firebird-mirror/src/intl/lc_unicode_ucs2.cpp

115 lines
3.9 KiB
C++
Raw Normal View History

2003-01-25 04:08:11 +01:00
/*
* PROGRAM: InterBase International support
* MODULE: lc_unicode_ucs2.c
* DESCRIPTION: Language Drivers in the Unicode family.
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
2003-02-17 11:37:42 +01:00
#include "firebird.h"
2003-01-25 04:08:11 +01:00
#include "../intl/ldcommon.h"
#include "lc_ascii.h"
#include "cv_unicode_fss.h"
2003-01-25 04:08:11 +01:00
STATIC SSHORT wc_mbtowc(TEXTTYPE *obj, UCS2_CHAR *wc, NCHAR *p, USHORT n);
2003-01-25 04:08:11 +01:00
#define FAMILY_UNICODE_WIDE_BIN(id_number, name, charset, country) \
cache->texttype_version = IB_LANGDRV_VERSION; \
cache->texttype_type = (id_number); \
cache->texttype_character_set = (charset); \
cache->texttype_country = (country); \
cache->texttype_bytes_per_char = 2; \
cache->texttype_fn_init = (FPTR_SHORT) (name); \
cache->texttype_fn_key_length = (FPTR_SHORT) famasc_key_length; \
cache->texttype_fn_string_to_key = (FPTR_SHORT) famasc_string_to_key; \
cache->texttype_fn_compare = (FPTR_short) famasc_compare; \
cache->texttype_fn_to_upper = (FPTR_SHORT) famasc_to_upper; \
cache->texttype_fn_to_lower = (FPTR_SHORT) famasc_to_lower; \
cache->texttype_fn_str_to_upper = (FPTR_short) famasc_str_to_upper; \
2003-01-25 04:08:11 +01:00
cache->texttype_collation_table = (BYTE *) NULL; \
cache->texttype_toupper_table = (BYTE *) NULL; \
cache->texttype_tolower_table = (BYTE *) NULL; \
cache->texttype_compress_table = (BYTE *) NULL; \
cache->texttype_expand_table = (BYTE *) NULL; \
cache->texttype_name = POSIX;
#define FAMILY_UNICODE_MB_BIN(id_number, name, charset, country) \
cache->texttype_version = IB_LANGDRV_VERSION; \
cache->texttype_type = (id_number); \
cache->texttype_character_set = (charset); \
cache->texttype_country = (country); \
cache->texttype_bytes_per_char = 3; \
cache->texttype_fn_init = (FPTR_SHORT) (name); \
cache->texttype_fn_key_length = (FPTR_SHORT) famasc_key_length; \
cache->texttype_fn_string_to_key = (FPTR_SHORT) famasc_string_to_key; \
cache->texttype_fn_compare = (FPTR_short) famasc_compare; \
cache->texttype_fn_to_upper = (FPTR_SHORT) famasc_to_upper; \
cache->texttype_fn_to_lower = (FPTR_SHORT) famasc_to_lower; \
cache->texttype_fn_str_to_upper = (FPTR_short) famasc_str_to_upper; \
2003-01-25 04:08:11 +01:00
cache->texttype_collation_table = (BYTE *) NULL; \
cache->texttype_toupper_table = (BYTE *) NULL; \
cache->texttype_tolower_table = (BYTE *) NULL; \
cache->texttype_compress_table = (BYTE *) NULL; \
cache->texttype_expand_table = (BYTE *) NULL; \
cache->texttype_name = POSIX;
TEXTTYPE_ENTRY(UNI200_init)
{
static ASCII POSIX[] = "C.UNICODE";
FAMILY_UNICODE_WIDE_BIN(200, UNI200_init, CS_UNICODE_UCS2, CC_C);
cache->texttype_fn_mbtowc = (FPTR_short) wc_mbtowc;
2003-01-25 04:08:11 +01:00
TEXTTYPE_RETURN;
}
#include "../intl/collations/undef.h"
TEXTTYPE_ENTRY(UNI201_init)
{
static ASCII POSIX[] = "C.UNICODE_FSS";
FAMILY_UNICODE_MB_BIN(201, UNI201_init, CS_UNICODE_FSS, CC_C);
cache->texttype_fn_to_wc = (FPTR_SHORT) CS_UTFFSS_fss_to_unicode;
cache->texttype_fn_mbtowc = (FPTR_short) CS_UTFFSS_fss_mbtowc;
2003-01-25 04:08:11 +01:00
TEXTTYPE_RETURN;
}
#include "../intl/collations/undef.h"
STATIC SSHORT wc_mbtowc(TEXTTYPE *obj, UCS2_CHAR *wc, NCHAR *p, USHORT n)
2003-01-25 04:08:11 +01:00
{
assert(obj);
assert(wc);
assert(p);
if (n < sizeof(UCS2_CHAR))
2003-01-25 04:08:11 +01:00
return -1;
*wc = *(UCS2_CHAR *) p;
return sizeof(UCS2_CHAR);
2003-01-25 04:08:11 +01:00
}
#undef FAMILY_UNICODE_MB_BIN
#undef FAMILY_UNICODE_WIDE_BIN