本文整理汇总了Java中com.ibm.icu.text.Transliterator.transform方法的典型用法代码示例。如果您正苦于以下问题:Java Transliterator.transform方法的具体用法?Java Transliterator.transform怎么用?Java Transliterator.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.text.Transliterator
的用法示例。
在下文中一共展示了Transliterator.transform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transliterate
import com.ibm.icu.text.Transliterator; //导入方法依赖的package包/类
public static String transliterate(String text, String transliterationCode) {
if (Str.isEmpty(text))
return text;
if (transliterationCode == null) {
transliterationCode = DEFAULT_TRANSLITERATION_CODE;
}
String transliteratedText = text.replace(ae, transliterateReplaceChars.get(ae))
.replace(oe, transliterateReplaceChars.get(oe)).replace(ue, transliterateReplaceChars.get(ue))
.replace(Ae, transliterateReplaceChars.get(Ae)).replace(Oe, transliterateReplaceChars.get(Oe))
.replace(Ue, transliterateReplaceChars.get(Ue)).replace(ss, transliterateReplaceChars.get(ss))
.replace(Str.AT, transliterateReplaceChars.get(Str.AT))
.replace(Str.AMPERSAND, transliterateReplaceChars.get(Str.AMPERSAND));
Transliterator t = transliteratorCache.get(transliterationCode);
if (t == null) {
t = Transliterator.getInstance(transliterationCode);
transliteratorCache.put(transliterationCode, t);
}
transliteratedText = t.transform(transliteratedText);
return Normalizer.normalize(transliteratedText, Normalizer.Form.NFD);
}
示例2: slugify
import com.ibm.icu.text.Transliterator; //导入方法依赖的package包/类
public static String slugify(String text, String transliterationCode) {
if (Str.isEmpty(text))
return text;
if (transliterationCode == null)
transliterationCode = DEFAULT_TRANSLITERATION_CODE;
String transliteratedText = text.replace(ae, transliterateReplaceChars.get(ae))
.replace(oe, transliterateReplaceChars.get(oe)).replace(ue, transliterateReplaceChars.get(ue))
.replace(Ae, transliterateReplaceChars.get(Ae)).replace(Oe, transliterateReplaceChars.get(Oe))
.replace(Ue, transliterateReplaceChars.get(Ue)).replace(ss, transliterateReplaceChars.get(ss))
.replace(Str.AT, transliterateReplaceChars.get(Str.AT))
.replace(Str.AMPERSAND, transliterateReplaceChars.get(Str.AMPERSAND));
Transliterator t = transliteratorCache.get(transliterationCode);
if (t == null) {
t = Transliterator.getInstance(transliterationCode);
transliteratorCache.put(transliterationCode, t);
}
transliteratedText = t.transform(transliteratedText);
transliteratedText = Normalizer.normalize(transliteratedText, Normalizer.Form.NFD)
.replace(Char.UNDERSCORE, Char.MINUS).replace(Char.SPACE, Char.MINUS).replace(Char.COMMA, Char.MINUS)
.replace(Char.DOT, Char.MINUS);
Matcher m1 = slugifyReplacePattern1.matcher(transliteratedText);
transliteratedText = m1.replaceAll(Str.EMPTY);
Matcher m2 = slugifyReplacePattern2.matcher(transliteratedText);
transliteratedText = m2.replaceAll(Str.EMPTY);
Matcher m3 = slugifyReplacePattern3.matcher(transliteratedText);
transliteratedText = m3.replaceAll(Str.MINUS);
Matcher m4 = slugifyReplacePattern4.matcher(transliteratedText);
transliteratedText = m4.replaceAll(Str.SPACE);
return transliteratedText.toLowerCase();
}
示例3: slugify2
import com.ibm.icu.text.Transliterator; //导入方法依赖的package包/类
public static String slugify2(String text, String transliterationCode) {
if (Str.isEmpty(text))
return text;
if (transliterationCode == null) {
transliterationCode = DEFAULT_TRANSLITERATION_CODE;
}
String transliteratedText = text.replace(ae, transliterateReplaceChars.get(ae))
.replace(oe, transliterateReplaceChars.get(oe)).replace(ue, transliterateReplaceChars.get(ue))
.replace(Ae, transliterateReplaceChars.get(Ae)).replace(Oe, transliterateReplaceChars.get(Oe))
.replace(Ue, transliterateReplaceChars.get(Ue)).replace(ss, transliterateReplaceChars.get(ss))
.replace(Str.AT, transliterateReplaceChars.get(Str.AT))
.replace(Str.AMPERSAND, transliterateReplaceChars.get(Str.AMPERSAND));
Transliterator t = transliteratorCache.get(transliterationCode);
if (t == null) {
t = Transliterator.getInstance(transliterationCode);
transliteratorCache.put(transliterationCode, t);
}
transliteratedText = t.transform(transliteratedText);
transliteratedText = Normalizer.normalize(transliteratedText, Normalizer.Form.NFD)
.replace(Char.UNDERSCORE, Char.MINUS).replace(Char.SPACE, Char.UNDERSCORE)
.replace(Char.COMMA, Char.MINUS).replace(Char.DOT, Char.MINUS);
Matcher m1 = slugifyReplacePattern1.matcher(transliteratedText);
transliteratedText = m1.replaceAll(Str.EMPTY);
Matcher m2 = slugifyReplacePattern2.matcher(transliteratedText);
transliteratedText = m2.replaceAll(Str.MINUS);
Matcher m3 = slugifyReplacePattern3.matcher(transliteratedText);
transliteratedText = m3.replaceAll(Str.MINUS);
Matcher m4 = slugifyReplacePattern4.matcher(transliteratedText);
transliteratedText = m4.replaceAll(Str.SPACE);
return transliteratedText.toLowerCase();
}