version 1.107, 2005/05/13 15:05:52
|
version 1.108, 2005/05/16 16:50:39
|
|
|
#include "InternalException.h" | #include "InternalException.h" |
#include <iostream> | #include <iostream> |
#include <fstream> | #include <fstream> |
|
#include <Pegasus/Common/CommonUTF.h> |
| |
#include "CommonUTF.h" | #include "CommonUTF.h" |
| |
|
|
void String::toLower() | void String::toLower() |
{ | { |
#ifdef PEGASUS_HAS_ICU | #ifdef PEGASUS_HAS_ICU |
|
if (InitializeICU::initICUSuccessful()) |
|
{ |
// This will do a locale-insensitive, but context-sensitive convert. | // This will do a locale-insensitive, but context-sensitive convert. |
// Context-sensitive prevents any optimizations that try to | // Context-sensitive prevents any optimizations that try to |
// convert just the ascii before calling ICU. | // convert just the ascii before calling ICU. |
|
|
} | } |
| |
delete [] destbuf; | delete [] destbuf; |
#else |
} |
|
else |
|
#endif |
|
{ |
for (Char16* p = &_rep->c16a[0]; *p; p++) | for (Char16* p = &_rep->c16a[0]; *p; p++) |
{ | { |
if (*p <= PEGASUS_MAX_PRINTABLE_CHAR) | if (*p <= PEGASUS_MAX_PRINTABLE_CHAR) |
*p = tolower(*p); | *p = tolower(*p); |
} | } |
#endif |
} |
} | } |
| |
void String::toUpper() | void String::toUpper() |
{ | { |
#ifdef PEGASUS_HAS_ICU | #ifdef PEGASUS_HAS_ICU |
|
if (InitializeICU::initICUSuccessful()) |
|
{ |
// This will do a locale-insensitive, but context-sensitive convert. | // This will do a locale-insensitive, but context-sensitive convert. |
// Context-sensitive prevents any optimizations that try to | // Context-sensitive prevents any optimizations that try to |
// convert just the ascii before calling ICU. | // convert just the ascii before calling ICU. |
|
|
} | } |
| |
delete [] destbuf; | delete [] destbuf; |
#else |
} |
|
else |
|
#endif |
|
{ |
for (Char16* p = &_rep->c16a[0]; *p; p++) | for (Char16* p = &_rep->c16a[0]; *p; p++) |
{ | { |
if (*p <= PEGASUS_MAX_PRINTABLE_CHAR) | if (*p <= PEGASUS_MAX_PRINTABLE_CHAR) |
*p = toupper(*p); | *p = toupper(*p); |
} | } |
#endif |
} |
} | } |
| |
int String::compare(const String& s1, const String& s2, Uint32 n) | int String::compare(const String& s1, const String& s2, Uint32 n) |
|
|
int String::compareNoCase(const String& s1, const String& s2) | int String::compareNoCase(const String& s1, const String& s2) |
{ | { |
#ifdef PEGASUS_HAS_ICU | #ifdef PEGASUS_HAS_ICU |
|
if (InitializeICU::initICUSuccessful()) |
|
{ |
return u_strcasecmp((const UChar*)s1.getChar16Data(), | return u_strcasecmp((const UChar*)s1.getChar16Data(), |
(const UChar*)s2.getChar16Data(), | (const UChar*)s2.getChar16Data(), |
U_FOLD_CASE_DEFAULT); | U_FOLD_CASE_DEFAULT); |
#else |
} |
|
#endif |
const Char16* _s1 = s1.getChar16Data(); | const Char16* _s1 = s1.getChar16Data(); |
const Char16* _s2 = s2.getChar16Data(); | const Char16* _s2 = s2.getChar16Data(); |
| |
|
|
return 1; | return 1; |
| |
return 0; | return 0; |
#endif |
|
} | } |
| |
Boolean String::equal(const String& str1, const String& str2) | Boolean String::equal(const String& str1, const String& str2) |
|
|
os << utf8str; | os << utf8str; |
| |
#elif defined(PEGASUS_HAS_ICU) | #elif defined(PEGASUS_HAS_ICU) |
|
if (InitializeICU::initICUSuccessful()) |
|
{ |
char *buf = NULL; | char *buf = NULL; |
const int size = str.size() * 6; | const int size = str.size() * 6; |
UnicodeString UniStr((const UChar *)str.getChar16Data(), (int32_t)str.size()); | UnicodeString UniStr((const UChar *)str.getChar16Data(), (int32_t)str.size()); |
|
|
os << buf; | os << buf; |
os.flush(); | os.flush(); |
delete [] buf; | delete [] buf; |
#else |
} |
|
else |
|
#endif // End of PEGASUS_HAS_ICU #else leg. |
|
{ |
for (Uint32 i = 0, n = str.size(); i < n; i++) | for (Uint32 i = 0, n = str.size(); i < n; i++) |
{ | { |
Uint16 code = str[i]; | Uint16 code = str[i]; |
|
|
os << buffer; | os << buffer; |
} | } |
} | } |
#endif // End of PEGASUS_HAS_ICU #else leg. |
} |
| |
return os; | return os; |
} | } |