use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method TestPatternQuoting.
/**
* Test pattern quoting and escape mechanisms.
*/
@Test
public void TestPatternQuoting() {
// Array of 3n items
// Each item is <rules>, <input>, <expected output>
String[] DATA = { "\u4E01>'[male adult]'", "\u4E01", "[male adult]" };
for (int i = 0; i < DATA.length; i += 3) {
logln("Pattern: " + Utility.escape(DATA[i]));
Transliterator t = Transliterator.createFromRules("<ID>", DATA[i], Transliterator.FORWARD);
expect(t, DATA[i + 1], DATA[i + 2]);
}
}
use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method TestSanskritLatinRT.
@Test
public void TestSanskritLatinRT() {
int MAX_LEN = 15;
String[] source = { "rmk\u1E63\u0113t", "\u015Br\u012Bmad", "bhagavadg\u012Bt\u0101", "adhy\u0101ya", "arjuna", "vi\u1E63\u0101da", "y\u014Dga", "dhr\u0325tar\u0101\u1E63\u1E6Dra", "uv\u0101cr\u0325", "dharmak\u1E63\u0113tr\u0113", "kuruk\u1E63\u0113tr\u0113", "samav\u0113t\u0101", "yuyutsava\u1E25", "m\u0101mak\u0101\u1E25", // "p\u0101\u1E47\u1E0Dav\u0101\u015Bcaiva",
"kimakurvata", "san\u0304java" };
String[] expected = { "\u0930\u094D\u092E\u094D\u0915\u094D\u0937\u0947\u0924\u094D", "\u0936\u094d\u0930\u0940\u092e\u0926\u094d", "\u092d\u0917\u0935\u0926\u094d\u0917\u0940\u0924\u093e", "\u0905\u0927\u094d\u092f\u093e\u092f", "\u0905\u0930\u094d\u091c\u0941\u0928", "\u0935\u093f\u0937\u093e\u0926", "\u092f\u094b\u0917", "\u0927\u0943\u0924\u0930\u093e\u0937\u094d\u091f\u094d\u0930", "\u0909\u0935\u093E\u091A\u0943", "\u0927\u0930\u094d\u092e\u0915\u094d\u0937\u0947\u0924\u094d\u0930\u0947", "\u0915\u0941\u0930\u0941\u0915\u094d\u0937\u0947\u0924\u094d\u0930\u0947", "\u0938\u092e\u0935\u0947\u0924\u093e", "\u092f\u0941\u092f\u0941\u0924\u094d\u0938\u0935\u0903", "\u092e\u093e\u092e\u0915\u093e\u0903", // "\u092a\u093e\u0923\u094d\u0921\u0935\u093e\u0936\u094d\u091a\u0948\u0935",
"\u0915\u093f\u092e\u0915\u0941\u0930\u094d\u0935\u0924", "\u0938\u0902\u091c\u0935" };
Transliterator latinToDev = Transliterator.getInstance("Latin-Devanagari", Transliterator.FORWARD);
Transliterator devToLatin = Transliterator.getInstance("Devanagari-Latin", Transliterator.FORWARD);
for (int i = 0; i < MAX_LEN; i++) {
expect(latinToDev, (source[i]), (expected[i]));
expect(devToLatin, (expected[i]), (source[i]));
}
}
use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method TestNameMap.
/**
* Test the name mapping transliterators.
*/
@Test
public void TestNameMap() {
Transliterator uni2name = Transliterator.getInstance("Any-Name[^abc]");
Transliterator name2uni = Transliterator.getInstance("Name-Any");
expect(uni2name, "\u00A0abc\u4E01\u00B5\u0A81\uFFFD\u0004\u0009\u0081\uFFFF", "\\N{NO-BREAK SPACE}abc\\N{CJK UNIFIED IDEOGRAPH-4E01}\\N{MICRO SIGN}\\N{GUJARATI SIGN CANDRABINDU}\\N{REPLACEMENT CHARACTER}\\N{<control-0004>}\\N{<control-0009>}\\N{<control-0081>}\\N{<noncharacter-FFFF>}");
expect(name2uni, "{\\N { NO-BREAK SPACE}abc\\N{ CJK UNIFIED IDEOGRAPH-4E01 }\\N{x\\N{MICRO SIGN}\\N{GUJARATI SIGN CANDRABINDU}\\N{REPLACEMENT CHARACTER}\\N{<control-0004>}\\N{<control-0009>}\\N{<control-0081>}\\N{<noncharacter-FFFF>}\\N{<control-0004>}\\N{", "{\u00A0abc\u4E01\\N{x\u00B5\u0A81\uFFFD\u0004\u0009\u0081\uFFFF\u0004\\N{");
// round trip
Transliterator t = Transliterator.getInstance("Any-Name;Name-Any");
String s = "{\u00A0abc\u4E01\\N{x\u00B5\u0A81\uFFFD\u0004\u0009\u0081\uFFFF\u0004\\N{";
expect(t, s, s);
}
use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method TestRemove.
/**
* Test the "Remove" transliterator.
*/
@Test
public void TestRemove() {
Transliterator t = Transliterator.getInstance("Remove[aeiou]");
expect(t, "The quick brown fox.", "Th qck brwn fx.");
}
use of android.icu.text.Transliterator in project j2objc by google.
the class TransliteratorTest method TestBeginEnd.
@Test
public void TestBeginEnd() {
// run through the list of test cases above
for (int i = 0; i < BEGIN_END_TEST_CASES.length; i += 3) {
expect(BEGIN_END_TEST_CASES[i], BEGIN_END_TEST_CASES[i + 1], BEGIN_END_TEST_CASES[i + 2]);
}
// instantiate the one reversible rule set in the reverse direction and make sure it does the right thing
Transliterator reversed = Transliterator.createFromRules("Reversed", BEGIN_END_RULES[17], Transliterator.REVERSE);
expect(reversed, "xy XY XYZ yz YZ", "xy abc xaba yz aba");
// finally, run through the list of syntactically-ill-formed rule sets above and make sure
// that all of them cause errors
/*
(commented out until we have the real ::BEGIN/::END stuff in place
for (int i = 0; i < BOGUS_BEGIN_END_RULES.length; i++) {
try {
Transliterator t = Transliterator.createFromRules("foo", BOGUS_BEGIN_END_RULES[i],
Transliterator.FORWARD);
errln("Should have gotten syntax error from " + BOGUS_BEGIN_END_RULES[i]);
}
catch (IllegalArgumentException e) {
// this is supposed to happen; do nothing here
}
}
*/
}
Aggregations