+ {
+ static const UScriptCode LATIN[1] = { USCRIPT_LATIN };
+ static const UScriptCode CYRILLIC[1] = { USCRIPT_CYRILLIC };
+ static const UScriptCode DEVANAGARI[1] = { USCRIPT_DEVANAGARI };
+ static const UScriptCode HAN[1] = { USCRIPT_HAN };
+ static const UScriptCode JAPANESE[3] = { USCRIPT_KATAKANA, USCRIPT_HIRAGANA, USCRIPT_HAN };
+ static const UScriptCode KOREAN[2] = { USCRIPT_HANGUL, USCRIPT_HAN };
+ static const UScriptCode HAN_BOPO[2] = { USCRIPT_HAN, USCRIPT_BOPOMOFO };
+ UScriptCode scripts[5];
+ UErrorCode err;
+ int32_t num;
+
+ // Should work regardless of whether we have locale data for the language.
+ err = U_ZERO_ERROR;
+ num = uscript_getCode("tg", scripts, UPRV_LENGTHOF(scripts), &err);
+ assertEqualScripts("tg script: Cyrl", CYRILLIC, 1, scripts, num, err); // Tajik
+ err = U_ZERO_ERROR;
+ num = uscript_getCode("xsr", scripts, UPRV_LENGTHOF(scripts), &err);
+ assertEqualScripts("xsr script: Deva", DEVANAGARI, 1, scripts, num, err); // Sherpa
+
+ // Multi-script languages.
+ err = U_ZERO_ERROR;
+ num = uscript_getCode("ja", scripts, UPRV_LENGTHOF(scripts), &err);
+ assertEqualScripts("ja scripts: Kana Hira Hani",
+ JAPANESE, UPRV_LENGTHOF(JAPANESE), scripts, num, err);
+ err = U_ZERO_ERROR;
+ num = uscript_getCode("ko", scripts, UPRV_LENGTHOF(scripts), &err);
+ assertEqualScripts("ko scripts: Hang Hani",
+ KOREAN, UPRV_LENGTHOF(KOREAN), scripts, num, err);
+ err = U_ZERO_ERROR;
+ num = uscript_getCode("zh", scripts, UPRV_LENGTHOF(scripts), &err);
+ assertEqualScripts("zh script: Hani", HAN, 1, scripts, num, err);
+ err = U_ZERO_ERROR;
+ num = uscript_getCode("zh-Hant", scripts, UPRV_LENGTHOF(scripts), &err);
+ assertEqualScripts("zh-Hant scripts: Hani Bopo", HAN_BOPO, 2, scripts, num, err);
+ err = U_ZERO_ERROR;
+ num = uscript_getCode("zh-TW", scripts, UPRV_LENGTHOF(scripts), &err);
+ assertEqualScripts("zh-TW scripts: Hani Bopo", HAN_BOPO, 2, scripts, num, err);
+
+ // Ambiguous API, but this probably wants to return Latin rather than Rongorongo (Roro).
+ err = U_ZERO_ERROR;
+ num = uscript_getCode("ro-RO", scripts, UPRV_LENGTHOF(scripts), &err);
+ assertEqualScripts("ro-RO script: Latn", LATIN, 1, scripts, num, err);
+ }