2
* PROGRAM: JRD International support
4
* DESCRIPTION: INTL Utility functions
6
* The contents of this file are subject to the Initial
7
* Developer's Public License Version 1.0 (the "License");
8
* you may not use this file except in compliance with the
9
* License. You may obtain a copy of the License at
10
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
12
* Software distributed under the License is distributed AS IS,
13
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
14
* See the License for the specific language governing rights
15
* and limitations under the License.
17
* The Original Code was created by Adriano dos Santos Fernandes
18
* for the Firebird Open Source RDBMS project.
20
* Copyright (c) 2006 Adriano dos Santos Fernandes <adrianosf@uol.com.br>
21
* and all contributors signed below.
23
* All Rights Reserved.
24
* Contributor(s): ______________________________________.
27
#ifndef JRD_INTLUTIL_H
28
#define JRD_INTLUTIL_H
30
#include "../common/classes/array.h"
31
#include "../common/classes/GenericMap.h"
32
#include "../common/classes/fb_string.h"
33
#include "../jrd/intlobj_new.h"
45
typedef Pair<Full<string, string> > SpecificAttribute;
46
typedef GenericMap<SpecificAttribute> SpecificAttributesMap;
49
static string generateSpecificAttributes(
50
Jrd::CharSet* cs, SpecificAttributesMap& map);
51
static bool parseSpecificAttributes(
52
Jrd::CharSet* cs, ULONG len, const UCHAR* s, SpecificAttributesMap* map);
54
static string convertAsciiToUtf16(const string& ascii);
55
static string convertUtf16ToAscii(const string& utf16, bool* error);
57
static ULONG cvtAsciiToUtf16(csconvert* obj, ULONG nSrc, const UCHAR* pSrc,
58
ULONG nDest, UCHAR* pDest, USHORT* err_code, ULONG* err_position);
59
static ULONG cvtUtf16ToAscii(csconvert* obj, ULONG nSrc, const UCHAR* pSrc,
60
ULONG nDest, UCHAR* pDest, USHORT* err_code, ULONG* err_position);
62
static void initAsciiCharset(charset* cs);
63
static void initConvert(csconvert* cvt, pfn_INTL_convert func);
64
static void initNarrowCharset(charset* cs, const ASCII* name);
65
static bool initUnicodeCollation(texttype* tt, charset* cs, const ASCII* name,
66
USHORT attributes, const UCharBuffer& specificAttributes, const string& configInfo);
68
static ULONG toLower(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
69
const ULONG* exceptions);
70
static ULONG toUpper(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
71
const ULONG* exceptions);
73
static bool readOneChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size);
75
static bool setupIcuAttributes(charset* cs, const string& specificAttributes,
76
const string& configInfo, string& newSpecificAttributes);
79
static string escapeAttribute(Jrd::CharSet* cs, const string& s);
80
static string unescapeAttribute(Jrd::CharSet* cs, const string& s);
82
static bool isAttributeEscape(Jrd::CharSet* cs, const UCHAR* s, ULONG size);
84
static bool readAttributeChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size, bool returnEscape);
87
} // namespace Firebird
89
#endif // JRD_INTLUTIL_H