X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..340931cb2e044a2141d11567dd0f782524e32994:/icuSources/test/letest/letsutil.cpp diff --git a/icuSources/test/letest/letsutil.cpp b/icuSources/test/letest/letsutil.cpp index edac65ac..1726b4e5 100644 --- a/icuSources/test/letest/letsutil.cpp +++ b/icuSources/test/letest/letsutil.cpp @@ -1,7 +1,9 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * - * Copyright (C) 1999-2006, International Business Machines + * Copyright (C) 1999-2014, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -20,7 +22,9 @@ #include "layout/LayoutEngine.h" #include "layout/LELanguages.h" +#ifndef USING_ICULEHB #include "OpenTypeLayoutEngine.h" +#endif #include "letest.h" #include "letsutil.h" @@ -43,6 +47,17 @@ char *getCString(const UnicodeString *uString) return cString; } +char *getCString(const LEUnicode16 *uChars) +{ + if (uChars == NULL) { + return NULL; + } + + const UnicodeString ustring(uChars); + + return getCString(&ustring); +} + char *getUTF8String(const UnicodeString *uString) { if (uString == NULL) { @@ -67,16 +82,20 @@ void freeCString(char *cString) le_bool getRTL(const UnicodeString &text) { - UBiDiLevel paraLevel; + UBiDiLevel level = 0; UErrorCode status = U_ZERO_ERROR; le_int32 charCount = text.length(); + le_int32 limit = -1; UBiDi *ubidi = ubidi_openSized(charCount, 0, &status); ubidi_setPara(ubidi, text.getBuffer(), charCount, UBIDI_DEFAULT_LTR, NULL, &status); - paraLevel = ubidi_getParaLevel(ubidi); + + // TODO: Should check that there's only a single logical run... + ubidi_getLogicalRun(ubidi, 0, &limit, &level); + ubidi_close(ubidi); - return paraLevel & 1; + return level & 1; } le_int32 getLanguageCode(const char *lang) @@ -87,11 +106,22 @@ le_int32 getLanguageCode(const char *lang) LETag langTag = (LETag) ((lang[0] << 24) + (lang[1] << 16) + (lang[2] << 8) + 0x20); +#ifndef USING_ICULEHB for (le_int32 i = 0; i < languageCodeCount; i += 1) { if (langTag == OpenTypeLayoutEngine::languageTags[i]) { return i; } } +#else + if (!strcmp(lang, "JAN")) return janLanguageCode; + if (!strcmp(lang, "KOR")) return korLanguageCode; + if (!strcmp(lang, "ZHT")) return zhtLanguageCode; + if (!strcmp(lang, "ZHS")) return zhsLanguageCode; + if (!strcmp(lang, "HIN")) return hinLanguageCode; + if (!strcmp(lang, "MAR")) return marLanguageCode; + if (!strcmp(lang, "ROM")) return romLanguageCode; +#endif + return -1; }