localeTest: fix corrupted characters.

This file used to hold iso-8859-15 encoded bytes for testing our char
conversion ability. However something went wrong and they all got
replaced by unicode "invalid character" mark. Use \x notation to escape
the actual bytes we want to test.
This commit is contained in:
Adrien Destugues 2014-09-29 14:56:02 +02:00
parent 27a2d2c7ef
commit bd0644183c
1 changed files with 21 additions and 16 deletions

View File

@ -26,19 +26,22 @@ main()
for (int32 i = 30; i < 70; i++) {
unicode_char_to_string(i, text);
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, defined == %d, charType == %d\n",
text,
BUnicodeChar::IsAlpha(i), BUnicodeChar::IsAlNum(i), BUnicodeChar::IsLower(i),
BUnicodeChar::IsUpper(i), BUnicodeChar::IsDefined(i), BUnicodeChar::Type(i));
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, "
"defined == %d, charType == %d\n", text,
BUnicodeChar::IsAlpha(i), BUnicodeChar::IsAlNum(i),
BUnicodeChar::IsLower(i), BUnicodeChar::IsUpper(i),
BUnicodeChar::IsDefined(i), BUnicodeChar::Type(i));
}
uint32 chars[] = {(uint8)'<EFBFBD>', (uint8)'<EFBFBD>', (uint8)'<EFBFBD>', (uint8)'<EFBFBD>', (uint8)'<EFBFBD>', (uint8)'<EFBFBD>', 0};
uint32 chars[] = {(uint8)'\xe4', (uint8)'\xd6', (uint8)'\xdf',
(uint8)'\xe8', (uint8)'\xe1', (uint8)'\xe9', 0};
for (int32 j = 0, i; (i = chars[j]) != 0; j++) {
unicode_char_to_string(i, text);
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, defined == %d, charType == %d\n",
text,
BUnicodeChar::IsAlpha(i), BUnicodeChar::IsAlNum(i), BUnicodeChar::IsLower(i),
BUnicodeChar::IsUpper(i), BUnicodeChar::IsDefined(i), BUnicodeChar::Type(i));
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, "
"defined == %d, charType == %d\n", text,
BUnicodeChar::IsAlpha(i), BUnicodeChar::IsAlNum(i),
BUnicodeChar::IsLower(i), BUnicodeChar::IsUpper(i),
BUnicodeChar::IsDefined(i), BUnicodeChar::Type(i));
unicode_char_to_string(BUnicodeChar::ToUpper(i), text);
printf("toUpper == %s, ", text);
@ -50,10 +53,11 @@ main()
for (int32 j = 0; utf8chars[j] != 0; j++) {
int32 i = BUnicodeChar::FromUTF8(utf8chars[j]);
unicode_char_to_string(i, text);
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, defined == %d, charType == %d\n",
text,
BUnicodeChar::IsAlpha(i), BUnicodeChar::IsAlNum(i), BUnicodeChar::IsLower(i),
BUnicodeChar::IsUpper(i), BUnicodeChar::IsDefined(i), BUnicodeChar::Type(i));
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, "
"defined == %d, charType == %d\n", text,
BUnicodeChar::IsAlpha(i), BUnicodeChar::IsAlNum(i),
BUnicodeChar::IsLower(i), BUnicodeChar::IsUpper(i),
BUnicodeChar::IsDefined(i), BUnicodeChar::Type(i));
unicode_char_to_string(BUnicodeChar::ToUpper(i), text);
printf("toUpper == %s, ", text);
@ -66,8 +70,8 @@ main()
BCollator collator;
BLocaleRoster::Default()->GetDefaultLocale()->GetCollator(&collator);
const char *strings[] = {"gehen", "géhen", "aus", "äUß", "auss", "äUß", "WO",
"", "SO", "so", "açñ", "acn", NULL};
const char *strings[] = {"gehen", "géhen", "aus", "äUß", "auss", "äUß",
"WO", "", "SO", "so", "açñ", "acn", NULL};
const char *strengths[] = {"primary: ", "secondary:", "tertiary: "};
for (int32 i = 0; strings[i]; i += 2) {
for (int32 strength = B_COLLATE_PRIMARY; strength < 4; strength++) {
@ -76,7 +80,8 @@ main()
collator.GetSortKey(strings[i + 1], &b, strength);
printf("%s sort keys: \"%s\" -> \"%s\", \"%s\" -> \"%s\"\n",
strengths[strength-1], strings[i], a.String(), strings[i+1], b.String());
strengths[strength-1], strings[i], a.String(), strings[i+1],
b.String());
printf("\tcmp = %d (key compare = %d)\n",
collator.Compare(strings[i], strings[i + 1], strength),
strcmp(a.String(), b.String()));