[英]Replace unicode characters?
I'm trying to show some html text in textview extracted from webview. 我正在尝试在从Webview提取的textview中显示一些html文本。 The returned string contains some unicode characters which I'm not able to replace. 返回的字符串包含一些我无法替换的unicode字符。 I created a class to replace these characters but it's not working 我创建了一个替换这些字符的类,但无法正常工作
public class Localizer {
String message;
public Localizer(String message){
this.message=message;
}
public String Localize(){
message = message.replaceAll("\\u0103","ă").replaceAll("\\u00EE","î").replaceAll("\\u0163","ţ").replaceAll("\\u015F","ş").replaceAll("\\u00E2","â").replaceAll("\\u00CE","Î").replaceAll("\\u0102","Ă");
return message;
}
}
and when I'm calling it, I use 当我打电话时,我使用
tvResultat.setText(new Localizer(Html.fromHtml(message)).Localize());
the output is still whit Unicode. 输出仍然是Unicode。 What am I doing wrong? 我究竟做错了什么?
解决方案将只是使用此类正则表达式保留ASCII符号
message = message.replace(/[^\x00-\x7F]/g, "");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.