8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-31 12:43:02 +01:00
firebird-mirror/src/intl/lc_ascii.cpp

644 lines
15 KiB
C++
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: InterBase International support
* MODULE: lc_ascii.cpp
2001-05-23 15:26:42 +02:00
* DESCRIPTION: Language Drivers in the binary collation 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"
2001-05-23 15:26:42 +02:00
#include "../intl/ldcommon.h"
2003-09-21 01:33:36 +02:00
#include "ld_proto.h"
#include "lc_ascii.h"
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
static inline bool FAMILY_ASCII(TEXTTYPE cache,
2003-09-19 00:06:59 +02:00
SSHORT country,
2005-05-28 00:45:31 +02:00
const ASCII* POSIX,
USHORT attributes,
const UCHAR* specific_attributes,
ULONG specific_attributes_length)
2003-09-19 00:06:59 +02:00
{
2005-05-28 00:45:31 +02:00
if ((attributes & ~TEXTTYPE_ATTR_PAD_SPACE) || specific_attributes_length)
return false;
cache->texttype_version = TEXTTYPE_VERSION_1;
cache->texttype_name = POSIX;
2003-09-19 00:06:59 +02:00
cache->texttype_country = country;
2005-05-28 00:45:31 +02:00
cache->texttype_pad_option = (attributes & TEXTTYPE_ATTR_PAD_SPACE) ? true : false;
2004-03-07 08:58:55 +01:00
cache->texttype_fn_key_length = famasc_key_length;
cache->texttype_fn_string_to_key= famasc_string_to_key;
cache->texttype_fn_compare = famasc_compare;
2005-05-28 00:45:31 +02:00
//cache->texttype_fn_str_to_upper = famasc_str_to_upper;
//cache->texttype_fn_str_to_lower = famasc_str_to_lower;
return true;
2003-09-19 00:06:59 +02:00
}
2001-05-23 15:26:42 +02:00
TEXTTYPE_ENTRY(DOS101_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS437";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(DOS107_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS865";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(DOS160_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS850";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(ISO88591_cp_init)
2001-05-23 15:26:42 +02:00
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_1";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY (ISO88592_cp_init)
2002-06-29 19:37:21 +02:00
{
2003-09-19 00:06:59 +02:00
static const ASCII POSIX[] = "C.ISO8859_2";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY (ISO88593_cp_init)
{
2003-09-19 00:06:59 +02:00
static const ASCII POSIX[] = "C.ISO8859_3";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY (ISO88594_cp_init)
{
2003-09-19 00:06:59 +02:00
static const ASCII POSIX[] = "C.ISO8859_4";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY (ISO88595_cp_init)
{
2003-09-19 00:06:59 +02:00
static const ASCII POSIX[] = "C.ISO8859_5";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY (ISO88596_cp_init)
{
2003-09-19 00:06:59 +02:00
static const ASCII POSIX[] = "C.ISO8859_6";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY (ISO88597_cp_init)
{
2003-09-19 00:06:59 +02:00
static const ASCII POSIX[] = "C.ISO8859_7";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY (ISO88598_cp_init)
{
2003-09-19 00:06:59 +02:00
static const ASCII POSIX[] = "C.ISO8859_8";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY (ISO88599_cp_init)
{
2003-09-19 00:06:59 +02:00
static const ASCII POSIX[] = "C.ISO8859_9";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY (ISO885913_cp_init)
{
2003-09-19 00:06:59 +02:00
static const ASCII POSIX[] = "C.ISO8859_13";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2002-06-29 19:37:21 +02:00
}
2001-05-23 15:26:42 +02:00
TEXTTYPE_ENTRY(DOS852_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS852";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(DOS857_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS857";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(DOS860_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS860";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(DOS861_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS861";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(DOS863_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS863";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(DOS737_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS737";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY(DOS775_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS775";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY(DOS858_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS858";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY(DOS862_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS862";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY(DOS864_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS864";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY(DOS866_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS866";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY(DOS869_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.DOS869";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
2001-05-23 15:26:42 +02:00
TEXTTYPE_ENTRY(CYRL_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.CYRL";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(WIN1250_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_1";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(WIN1251_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_1";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
if (FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length))
{
cache->texttype_fn_str_to_upper = cp1251_str_to_upper;
cache->texttype_fn_str_to_lower = cp1251_str_to_lower;
return true;
}
else
return false;
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(WIN1252_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_1";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(WIN1253_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_1";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(WIN1254_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_1";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(WIN1255_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_5";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY(WIN1256_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_1";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY(WIN1257_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_1";
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
2001-05-23 15:26:42 +02:00
TEXTTYPE_ENTRY(NEXT_c0_init)
{
2003-02-13 10:58:19 +01:00
static const ASCII POSIX[] = "C.ISO8859_1";
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
2001-05-23 15:26:42 +02:00
}
TEXTTYPE_ENTRY(KOI8R_c0_init)
{
static const ASCII POSIX[] = "C.KOI8R";
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
TEXTTYPE_ENTRY(KOI8U_c0_init)
{
static const ASCII POSIX[] = "C.KOI8U";
return FAMILY_ASCII(cache, CC_C, POSIX, attributes, specific_attributes, specific_attributes_length);
}
2001-05-23 15:26:42 +02:00
/*
* Generic base for InterBase 4.0 Language Driver - ASCII family (binary
* 8 bit sorting)
*/
2004-05-18 23:58:19 +02:00
const USHORT LANGASCII_MAX_KEY = MAX_KEY;
const BYTE ASCII_SPACE = 32; // ASCII code for space
2001-05-23 15:26:42 +02:00
#define ASCII7_UPPER(ch) \
((((UCHAR) (ch) >= (UCHAR) ASCII_LOWER_A) && ((UCHAR) (ch) <= (UCHAR) ASCII_LOWER_Z)) \
? (UCHAR) ((ch)-ASCII_LOWER_A+ASCII_UPPER_A) \
: (UCHAR) (ch))
#define ASCII7_LOWER(ch) \
((((UCHAR) (ch) >= (UCHAR) ASCII_UPPER_A) && ((UCHAR) (ch) <= (UCHAR) ASCII_UPPER_Z)) \
? (UCHAR) ((ch)-ASCII_UPPER_A+ASCII_LOWER_A) \
: (UCHAR) (ch))
2004-05-18 18:32:07 +02:00
const UCHAR CP1251_UPPER_A = 0xC0;
const UCHAR CP1251_LOWER_A = 0xE0;
const UCHAR CP1251_UPPER_YA = 0xDF;
const UCHAR CP1251_LOWER_YA = 0xFF;
const UCHAR CP1251_UPPER_EX0 = 0xA8; // <20>
const UCHAR CP1251_LOWER_EX0 = 0xB8; // <20>
const UCHAR CP1251_UPPER_EX1 = 0xA5; // <20>
const UCHAR CP1251_LOWER_EX1 = 0xB4; // <20>
const UCHAR CP1251_UPPER_EX2 = 0xAA; // <20>
const UCHAR CP1251_LOWER_EX2 = 0xBA; // <20>
const UCHAR CP1251_UPPER_EX3 = 0xAF; // <20>
const UCHAR CP1251_LOWER_EX3 = 0xBF; // <20>
const UCHAR CP1251_UPPER_EX4 = 0xB2; // <20>
const UCHAR CP1251_LOWER_EX4 = 0xB3; // <20>
2004-03-07 08:58:55 +01:00
static inline UCHAR CP1251_UPPER(UCHAR ch)
{
UCHAR res;
if (ch >= ASCII_LOWER_A && ch <= ASCII_LOWER_Z)
{
res = ch - ASCII_LOWER_A + ASCII_UPPER_A;
}
else if (ch >= CP1251_LOWER_A && ch <= CP1251_LOWER_YA)
{
res = ch - CP1251_LOWER_A + CP1251_UPPER_A;
}
else
{
switch (ch)
{
case CP1251_LOWER_EX0:
res = CP1251_UPPER_EX0;
break;
case CP1251_LOWER_EX1:
res = CP1251_UPPER_EX1;
break;
case CP1251_LOWER_EX2:
res = CP1251_UPPER_EX2;
break;
case CP1251_LOWER_EX3:
res = CP1251_UPPER_EX3;
break;
case CP1251_LOWER_EX4:
res = CP1251_UPPER_EX4;
break;
default:
res = ch;
}
}
return res;
}
2004-03-07 08:58:55 +01:00
static inline UCHAR CP1251_LOWER(UCHAR ch)
{
UCHAR res;
if (ch >= ASCII_UPPER_A && ch <= ASCII_UPPER_Z)
{
res = ch - ASCII_UPPER_A + ASCII_LOWER_A;
}
else if (ch >= CP1251_UPPER_A && ch <= CP1251_UPPER_YA)
{
res = ch - CP1251_UPPER_A + CP1251_LOWER_A;
}
else
{
switch (ch)
{
case CP1251_UPPER_EX0:
res = CP1251_LOWER_EX0;
break;
case CP1251_UPPER_EX1:
res = CP1251_LOWER_EX1;
break;
case CP1251_UPPER_EX2:
res = CP1251_LOWER_EX2;
break;
case CP1251_UPPER_EX3:
res = CP1251_LOWER_EX3;
break;
case CP1251_UPPER_EX4:
res = CP1251_LOWER_EX4;
break;
default:
res = ch;
}
}
return res;
}
2001-05-23 15:26:42 +02:00
/*
* key_length (in_len)
*
* For an input string of (in_len) bytes, return the maximum
* key buffer length.
*
* This is used for index buffer allocation within the
* Engine.
*/
USHORT famasc_key_length(TEXTTYPE obj, USHORT inLen)
2001-05-23 15:26:42 +02:00
{
2003-11-04 00:59:24 +01:00
/* fb_assert (inLen <= LANGASCII_MAX_KEY); - possible upper logic error if true */
2001-05-23 15:26:42 +02:00
return (MIN(inLen, LANGASCII_MAX_KEY));
}
/*
*
* Convert a user string to a sequence that will collate bytewise.
*
* For ASCII type collation (codepoint collation) this mearly
* involves stripping the space character off the key.
*
* RETURN:
* Length, in bytes, of returned key
*/
2004-03-07 08:58:55 +01:00
USHORT famasc_string_to_key(TEXTTYPE obj, USHORT iInLen, const BYTE* pInChar, USHORT iOutLen, BYTE *pOutChar,
2005-05-28 00:45:31 +02:00
USHORT key_type) // unused
2001-05-23 15:26:42 +02:00
{
2003-11-04 00:59:24 +01:00
fb_assert(pOutChar != NULL);
fb_assert(pInChar != NULL);
fb_assert(iInLen <= LANGASCII_MAX_KEY);
fb_assert(iOutLen <= LANGASCII_MAX_KEY);
fb_assert(iOutLen >= famasc_key_length(obj, iInLen));
2001-05-23 15:26:42 +02:00
/* point inbuff at last character */
2004-03-07 08:58:55 +01:00
const BYTE* inbuff = pInChar + iInLen - 1;
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
if (obj->texttype_pad_option)
{
/* skip backwards over all spaces & reset input length */
while ((inbuff >= pInChar) && (*inbuff == ASCII_SPACE))
inbuff--;
}
2001-05-23 15:26:42 +02:00
iInLen = (inbuff - pInChar + 1);
2004-03-07 08:58:55 +01:00
BYTE* outbuff = pOutChar;
2001-05-23 15:26:42 +02:00
while (iInLen-- && iOutLen--) {
*outbuff++ = *pInChar++;
}
return (outbuff - pOutChar);
}
2005-05-28 00:45:31 +02:00
static bool all_spaces(const BYTE* s, SLONG len)
2001-05-23 15:26:42 +02:00
{
2003-11-04 00:59:24 +01:00
fb_assert(s != NULL);
2001-05-23 15:26:42 +02:00
while (len-- > 0) {
2001-05-23 15:26:42 +02:00
if (*s++ != ASCII_SPACE)
2004-03-07 08:58:55 +01:00
return false;
}
2004-03-07 08:58:55 +01:00
return true;
2001-05-23 15:26:42 +02:00
}
2005-05-28 00:45:31 +02:00
SSHORT famasc_compare(TEXTTYPE obj, ULONG l1, const BYTE* s1, ULONG l2, const BYTE* s2,
INTL_BOOL* error_flag)
2001-05-23 15:26:42 +02:00
{
2003-11-04 00:59:24 +01:00
fb_assert(obj != NULL);
fb_assert(s1 != NULL);
fb_assert(s2 != NULL);
2005-05-28 00:45:31 +02:00
fb_assert(error_flag != NULL);
*error_flag = false;
2001-05-23 15:26:42 +02:00
2005-05-28 00:45:31 +02:00
const ULONG len = MIN(l1, l2);
for (ULONG i = 0; i < len; i++) {
2001-05-23 15:26:42 +02:00
if (s1[i] == s2[i])
continue;
2005-05-28 00:45:31 +02:00
else if (all_spaces(&s1[i], (SLONG) (l1 - i)))
2001-05-23 15:26:42 +02:00
return -1;
2005-05-28 00:45:31 +02:00
else if (all_spaces(&s2[i], (SLONG) (l2 - i)))
2001-05-23 15:26:42 +02:00
return 1;
else if (s1[i] < s2[i])
return -1;
else
return 1;
}
if (l1 > len) {
2005-05-28 00:45:31 +02:00
if (obj->texttype_pad_option && all_spaces(&s1[len], (SLONG) (l1 - len)))
2001-05-23 15:26:42 +02:00
return 0;
return 1;
}
if (l2 > len) {
2005-05-28 00:45:31 +02:00
if (obj->texttype_pad_option && all_spaces(&s2[len], (SLONG) (l2 - len)))
2001-05-23 15:26:42 +02:00
return 0;
return -1;
}
return (0);
}
2005-05-28 00:45:31 +02:00
ULONG famasc_str_to_upper(TEXTTYPE obj, ULONG iLen, const BYTE* pStr, ULONG iOutLen, BYTE *pOutStr)
2001-05-23 15:26:42 +02:00
{
2003-11-04 00:59:24 +01:00
fb_assert(pStr != NULL);
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
2003-12-31 06:36:12 +01:00
const BYTE* const p = pOutStr;
2001-05-23 15:26:42 +02:00
while (iLen && iOutLen) {
*pOutStr++ = ASCII7_UPPER(*pStr);
pStr++;
iLen--;
iOutLen--;
}
2001-05-23 15:26:42 +02:00
if (iLen != 0)
2005-05-28 00:45:31 +02:00
return INTL_BAD_STR_LENGTH;
2001-05-23 15:26:42 +02:00
return (pOutStr - p);
}
2005-05-28 00:45:31 +02:00
ULONG famasc_str_to_lower(TEXTTYPE obj, ULONG iLen, const BYTE* pStr, ULONG iOutLen, BYTE *pOutStr)
{
2005-05-28 00:45:31 +02:00
fb_assert(pStr != NULL);
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
*pOutStr++ = ASCII7_LOWER(*pStr);
pStr++;
iLen--;
iOutLen--;
}
if (iLen != 0)
return INTL_BAD_STR_LENGTH;
return (pOutStr - p);
}
2005-05-28 00:45:31 +02:00
ULONG cp1251_str_to_upper(TEXTTYPE obj, ULONG iLen, const BYTE* pStr, ULONG iOutLen, BYTE *pOutStr)
{
2003-11-04 00:59:24 +01:00
fb_assert(pStr != NULL);
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
2003-12-31 06:36:12 +01:00
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
*pOutStr++ = CP1251_UPPER(*pStr);
pStr++;
iLen--;
iOutLen--;
}
if (iLen != 0)
2005-05-28 00:45:31 +02:00
return INTL_BAD_STR_LENGTH;
return (pOutStr - p);
}
2005-05-28 00:45:31 +02:00
ULONG cp1251_str_to_lower(TEXTTYPE obj, ULONG iLen, const BYTE* pStr, ULONG iOutLen, BYTE *pOutStr)
{
2005-05-28 00:45:31 +02:00
fb_assert(pStr != NULL);
fb_assert(pOutStr != NULL);
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
*pOutStr++ = CP1251_LOWER(*pStr);
pStr++;
iLen--;
iOutLen--;
}
if (iLen != 0)
return INTL_BAD_STR_LENGTH;
return (pOutStr - p);
}