Android 安卓系统中乌尔都语代码的解码

Android 安卓系统中乌尔都语代码的解码,android,fonts,arabic,android-typeface,urdu,Android,Fonts,Arabic,Android Typeface,Urdu,我正在调用一个API,并收到了英文和乌尔都语的响应。响应存储在字符串中,乌尔都语部分显示字符文本,如“/u024/” 我已经实现了这个代码集,它为乌尔都语字符提供了与以前相同的结果。如果有人能帮我解决这个问题,我会很感激的 String fontPath = "urdu.ttf"; // text view label TextView txtGhost = (TextView) findViewById(R.id.ghost); // Loading Fon

我正在调用一个API,并收到了英文和乌尔都语的响应。响应存储在字符串中,乌尔都语部分显示字符文本,如“/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);

请尝试使用此字体,而不是当前字体:

那么,在你的案例中你犯了什么错误

有关语言支持的更多信息:

您对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;
}
更多信息:请参见此


为什么在设置文本之后再设置字体?顺便说一句,它没有起作用。{“success”:“100”,“message”:“successful”,“name”:“\u0645\u062d\u0645\u062f\u0639\u0628\u062f\u0627\u0644\u0644\u0644\u0647\u0627\u0639\u0638\u0645\u062e\u0627\u0646”}这是API的精确返回,存储在字符串中,\u062f\etc部分是乌尔都字符。无论存储什么,如果字符串中的任何单词/字符为UTF/html格式,则它将自动转换为html\n我已尝试了您发布的第二个代码,但应用程序因未知原因崩溃。在logcat上也找不到任何东西让我试试,很快会给你解决方案
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