From bd0644183c84d8bb2c8f0f6b2f4b406da7a825e0 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 29 Sep 2014 14:56:02 +0200 Subject: [PATCH] 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. --- src/tests/kits/locale/localeTest.cpp | 37 ++++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/tests/kits/locale/localeTest.cpp b/src/tests/kits/locale/localeTest.cpp index c40bb97740..02f0e50c7e 100644 --- a/src/tests/kits/locale/localeTest.cpp +++ b/src/tests/kits/locale/localeTest.cpp @@ -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)'�', (uint8)'�', (uint8)'�', (uint8)'�', (uint8)'�', (uint8)'�', 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", - "wÖ", "SO", "so", "açñ", "acn", NULL}; + const char *strings[] = {"gehen", "géhen", "aus", "äUß", "auss", "äUß", + "WO", "wÖ", "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()));