use of android.icu.text.Transliterator in project j2objc by google.
the class JamoTest method TestRoundTrip.
/**
* These are problems turned up by the Hangul-Jamo;Jamo-Latin
* round trip test.
*/
@Test
public void TestRoundTrip() {
String[] HANGUL = { "\uAC03\uC2F8", "\uC544\uC5B4" };
Transliterator latinJamo = Transliterator.getInstance("Latin-Jamo");
Transliterator jamoLatin = latinJamo.getInverse();
Transliterator jamoHangul = Transliterator.getInstance("NFC");
Transliterator hangulJamo = Transliterator.getInstance("NFD");
StringBuffer buf = new StringBuffer();
for (int i = 0; i < HANGUL.length; ++i) {
String hangul = HANGUL[i];
String jamo = hangulJamo.transliterate(hangul);
String latin = jamoLatin.transliterate(jamo);
String jamo2 = latinJamo.transliterate(latin);
String hangul2 = jamoHangul.transliterate(jamo2);
buf.setLength(0);
buf.append(hangul + " => " + jamoToName(jamo) + " => " + latin + " => " + jamoToName(jamo2) + " => " + hangul2);
if (!hangul.equals(hangul2)) {
errln("FAIL: " + Utility.escape(buf.toString()));
} else {
logln(Utility.escape(buf.toString()));
}
}
}
use of android.icu.text.Transliterator in project j2objc by google.
the class ReplaceableTest method check.
void check(String transliteratorName, String test, String shouldProduceStyles) {
TestReplaceable tr = new TestReplaceable(test, null);
String original = tr.toString();
Transliterator t;
if (transliteratorName.startsWith("*")) {
transliteratorName = transliteratorName.substring(1);
t = Transliterator.createFromRules("test", transliteratorName, Transliterator.FORWARD);
} else {
t = Transliterator.getInstance(transliteratorName);
}
t.transliterate(tr);
String newStyles = tr.getStyles();
if (!newStyles.equals(shouldProduceStyles)) {
errln("FAIL Styles: " + transliteratorName + " ( " + original + " ) => " + tr.toString() + "; should be {" + shouldProduceStyles + "}!");
} else {
logln("OK: " + transliteratorName + " ( " + original + " ) => " + tr.toString());
}
if (!tr.hasMetaData() || tr.chars.hasMetaData() || tr.styles.hasMetaData()) {
errln("Fail hasMetaData()");
}
}
Aggregations