解码 Android 中的乌尔都语代码
Decoding Urdu Codes in Android
我打电话给 API 并收到英语和乌尔都语回复。响应存储在一个字符串中,urdu 部分显示字符文本,如“/u024/”。
我一直在实施这个代码集,它为乌尔都语字符提供与以前相同的结果。如果有人可以帮助我解决这个问题
String fontPath = "urdu.ttf";
// text view label
TextView txtGhost = (TextView) findViewById(R.id.ghost);
// Loading Font Face
Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
// Applying font
txtGhost.setTypeface(tf);
尝试使用此字体代替您当前的字体:http://www.quran.or.kr/urdu/font/asunaskh.ttf
try {
txtGhost.setTypeface(Typeface.createFromAsset(this.getAssets(),"asunaskh.ttf"));
txtGhost.setText("ur text");
}
catch(Exception ex) {
Log.e("TAG", ex.toString());
}
还有,您遇到了什么错误?
有关语言支持的更多信息:how to add language support to android
您在 Unicode 中的回复,
试试这个
TextView tv=(TextView)findViewById(R.id.textViewmyView);
final Typeface tf = Typeface.createFromAsset(this.getAssets(),"asunaskh.ttf");
tv.setTypeface(tf);
tv.setText(Html.fromHtml(yourText);
如果以上不起作用,请添加此内容
String str = myString.split(" ")[0];
str = str.replace("\","");
String[] arr = str.split("u");
String text = "";
for(int i = 1; i < arr.length; i++){
int hexVal = Integer.parseInt(arr[i], 16);
text += (char)hexVal;
}
或这个
textview.setText(Html.from(StringEscapeUtils.unescapeJava(unicode))); //this method
更多信息:请参阅此 How to use unicode in Android resource?
How to convert a string with Unicode encoding to a string of letters
我打电话给 API 并收到英语和乌尔都语回复。响应存储在一个字符串中,urdu 部分显示字符文本,如“/u024/”。
我一直在实施这个代码集,它为乌尔都语字符提供与以前相同的结果。如果有人可以帮助我解决这个问题
String fontPath = "urdu.ttf";
// text view label
TextView txtGhost = (TextView) findViewById(R.id.ghost);
// Loading Font Face
Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
// Applying font
txtGhost.setTypeface(tf);
尝试使用此字体代替您当前的字体:http://www.quran.or.kr/urdu/font/asunaskh.ttf
try {
txtGhost.setTypeface(Typeface.createFromAsset(this.getAssets(),"asunaskh.ttf"));
txtGhost.setText("ur text");
}
catch(Exception ex) {
Log.e("TAG", ex.toString());
}
还有,您遇到了什么错误?
有关语言支持的更多信息:how to add language support to android
您在 Unicode 中的回复, 试试这个
TextView tv=(TextView)findViewById(R.id.textViewmyView);
final Typeface tf = Typeface.createFromAsset(this.getAssets(),"asunaskh.ttf");
tv.setTypeface(tf);
tv.setText(Html.fromHtml(yourText);
如果以上不起作用,请添加此内容
String str = myString.split(" ")[0];
str = str.replace("\","");
String[] arr = str.split("u");
String text = "";
for(int i = 1; i < arr.length; i++){
int hexVal = Integer.parseInt(arr[i], 16);
text += (char)hexVal;
}
或这个
textview.setText(Html.from(StringEscapeUtils.unescapeJava(unicode))); //this method
更多信息:请参阅此 How to use unicode in Android resource?
How to convert a string with Unicode encoding to a string of letters