From: John Hodge Date: Sun, 23 Jun 2013 06:48:20 +0000 (+0800) Subject: Kernel/UTF-16 - Added case-insensitive compre (for NTFS indexes) X-Git-Tag: rel0.15~415 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ad0fcdef1e9db0d031dc1bd4f28c51949f2d8072;p=tpg%2Facess2.git Kernel/UTF-16 - Added case-insensitive compre (for NTFS indexes) --- diff --git a/KernelLand/Kernel/include/utf16.h b/KernelLand/Kernel/include/utf16.h index 0a6666cf..9d4785cf 100644 --- a/KernelLand/Kernel/include/utf16.h +++ b/KernelLand/Kernel/include/utf16.h @@ -10,7 +10,9 @@ extern int ReadUTF16(const Uint16 *Str16, Uint32 *Codepoint); extern size_t UTF16_ConvertToUTF8(size_t DestLen, char *Dest, size_t SrcLen, const Uint16 *Source); +extern int UTF16_CompareWithUTF8Ex(size_t Str16Len, const Uint16 *Str16, const char *Str8, int bIgnoreCase); extern int UTF16_CompareWithUTF8(size_t Str16Len, const Uint16 *Str16, const char *Str8); +extern int UTF16_CompareWithUTF8CI(size_t Str16Len, const Uint16 *Str16, const char *Str8); #endif diff --git a/KernelLand/Kernel/utf16.c b/KernelLand/Kernel/utf16.c index 514fc7cb..3f27df39 100644 --- a/KernelLand/Kernel/utf16.c +++ b/KernelLand/Kernel/utf16.c @@ -5,7 +5,7 @@ * utf16.c * - UTF-16 Translation/Manipulation */ -#define DEBUG 1 +#define DEBUG 0 #include #include @@ -48,7 +48,7 @@ size_t UTF16_ConvertToUTF8(size_t DestLen, char *Dest, size_t SrcLen, const Uint return len; } -int UTF16_CompareWithUTF8(size_t Str16Len, const Uint16 *Str16, const char *Str8) +int UTF16_CompareWithUTF8Ex(size_t Str16Len, const Uint16 *Str16, const char *Str8, int bCaseInsensitive) { int pos16 = 0, pos8 = 0; const Uint8 *str8 = (const Uint8 *)Str8; @@ -58,6 +58,10 @@ int UTF16_CompareWithUTF8(size_t Str16Len, const Uint16 *Str16, const char *Str8 Uint32 cp8, cp16; pos16 += ReadUTF16(Str16+pos16, &cp16); pos8 += ReadUTF8(str8 + pos8, &cp8); + if( bCaseInsensitive ) { + cp16 = toupper(cp16); + cp8 = toupper(cp8); + } LOG("cp16 = %x, cp8 = %x", cp16, cp8); if(cp16 == cp8) continue ; @@ -77,3 +81,13 @@ int UTF16_CompareWithUTF8(size_t Str16Len, const Uint16 *Str16, const char *Str8 return -1; } +int UTF16_CompareWithUTF8(size_t Str16Len, const Uint16 *Str16, const char *Str8) +{ + return UTF16_CompareWithUTF8Ex(Str16Len, Str16, Str8, 0); +} + +int UTF16_CompareWithUTF8CI(size_t Str16Len, const Uint16 *Str16, const char *Str8) +{ + return UTF16_CompareWithUTF8Ex(Str16Len, Str16, Str8, 1); +} +