8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-27 20:43:03 +01:00
firebird-mirror/src/jrd/unicode_util.h

114 lines
4.0 KiB
C
Raw Normal View History

2005-05-28 00:45:31 +02:00
/*
* PROGRAM: JRD International support
* MODULE: unicode_util.h
* DESCRIPTION: Unicode functions
*
* The contents of this file are subject to the Initial
* Developer's 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.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
*
* Software distributed under the License is distributed AS IS,
* 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 Adriano dos Santos Fernandes
* for the Firebird Open Source RDBMS project.
*
* Copyright (c) 2004 Adriano dos Santos Fernandes <adrianosf@uol.com.br>
* and all contributors signed below.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef JRD_UNICODE_UTIL_H
#define JRD_UNICODE_UTIL_H
#include "intlobj_new.h"
#include "../jrd/IntlUtil.h"
#include "../jrd/os/mod_loader.h"
2008-02-26 08:23:32 +01:00
//#include "unicode/ucol.h"
//#include "unicode/ucnv.h"
struct UCollator;
struct USet;
2005-05-28 00:45:31 +02:00
namespace Jrd {
class UnicodeUtil
{
private:
struct ICU;
2005-05-28 00:45:31 +02:00
public:
class ICUModules;
2005-06-21 03:44:43 +02:00
// routines semantically equivalent with intlobj_new.h
2005-05-28 00:45:31 +02:00
static USHORT utf16KeyLength(USHORT len); // BOCU-1
static USHORT utf16ToKey(USHORT srcLen, const USHORT* src, USHORT dstLen, UCHAR* dst,
USHORT key_type); // BOCU-1
static ULONG utf16LowerCase(ULONG srcLen, const USHORT* src, ULONG dstLen, USHORT* dst, const ULONG* exceptions);
static ULONG utf16UpperCase(ULONG srcLen, const USHORT* src, ULONG dstLen, USHORT* dst, const ULONG* exceptions);
2005-05-28 00:45:31 +02:00
static ULONG utf16ToUtf8(ULONG srcLen, const USHORT* src, ULONG dstLen, UCHAR* dst,
USHORT* err_code, ULONG* err_position);
static ULONG utf8ToUtf16(ULONG srcLen, const UCHAR* src, ULONG dstLen, USHORT* dst,
USHORT* err_code, ULONG* err_position);
static ULONG utf16ToUtf32(ULONG srcLen, const USHORT* src, ULONG dstLen, ULONG* dst,
USHORT* err_code, ULONG* err_position);
static ULONG utf32ToUtf16(ULONG srcLen, const ULONG* src, ULONG dstLen, USHORT* dst,
USHORT* err_code, ULONG* err_position);
static SSHORT utf16Compare(ULONG len1, const USHORT* str1, ULONG len2, const USHORT* str2,
INTL_BOOL* error_flag);
static ULONG utf16Length(ULONG len, const USHORT* str);
static ULONG utf16Substring(ULONG srcLen, const USHORT* src, ULONG dstLen, USHORT* dst,
ULONG startPos, ULONG length);
static INTL_BOOL utf8WellFormed(ULONG len, const UCHAR* str, ULONG* offending_position);
static INTL_BOOL utf16WellFormed(ULONG len, const USHORT* str, ULONG* offending_position);
static INTL_BOOL utf32WellFormed(ULONG len, const ULONG* str, ULONG* offending_position);
static ICU* loadICU(const Firebird::string& icuVersion, const Firebird::string& configInfo);
static bool getCollVersion(const Firebird::string& icuVersion,
const Firebird::string& configInfo, Firebird::string& collVersion);
2005-05-28 00:45:31 +02:00
class Utf16Collation
{
public:
static Utf16Collation* create(
texttype* tt, USHORT attributes,
Firebird::IntlUtil::SpecificAttributesMap& specificAttributes,
const Firebird::string& configInfo);
2005-05-28 00:45:31 +02:00
~Utf16Collation();
2006-02-24 02:33:38 +01:00
USHORT keyLength(USHORT len) const;
2005-05-28 00:45:31 +02:00
USHORT stringToKey(USHORT srcLen, const USHORT* src, USHORT dstLen, UCHAR* dst,
2006-02-24 02:33:38 +01:00
USHORT key_type) const;
2005-05-28 00:45:31 +02:00
SSHORT compare(ULONG len1, const USHORT* str1, ULONG len2, const USHORT* str2,
2006-02-24 02:33:38 +01:00
INTL_BOOL* error_flag) const;
ULONG canonical(ULONG srcLen, const USHORT* src, ULONG dstLen, ULONG* dst, const ULONG* exceptions);
2005-05-28 00:45:31 +02:00
private:
static ICU* loadICU(const Firebird::string& collVersion, const Firebird::string& locale,
const Firebird::string& configInfo);
ICU* icu;
texttype* tt;
USHORT attributes;
2008-02-26 08:23:32 +01:00
UCollator* compareCollator;
UCollator* partialCollator;
UCollator* sortCollator;
USet* contractions;
int contractionsCount;
2005-05-28 00:45:31 +02:00
};
2007-04-18 13:02:41 +02:00
friend class Utf16Collation;
2005-05-28 00:45:31 +02:00
};
} // namespace Jrd
#endif // JRD_UNICODE_UTIL_H