解码乌尔都语codeS Android中 [英] Decoding Urdu Codes in Android
问题描述
我调用API和接受英语和乌尔都语的响应。响应被存储在字符串和乌尔都语部分显示字符的文本,如/ U024 /。
我一直在执行其作为前给予相同的结果为乌尔都语这个字符code组。请如果有人能帮助我走出这个
字符串的FontPath =urdu.ttf; //文本视图标签
TextView的txtGhost =(的TextView)findViewById(R.id.ghost); //加载字体面
字体TF = Typeface.createFromAsset(getAssets(),字体路径); //字体的应用
txtGhost.setTypeface(TF);
您在统一code响应,
试试这个
TextView的电视=(的TextView)findViewById(R.id.textViewmyView);
最终字样TF = Typeface.createFromAsset(this.getAssets(),asunaskh.ttf);
tv.setTypeface(TF);
tv.setText(Html.fromHtml(yourText);
添加此,如果上述方法无效
字符串str = myString.split()[0];
海峡= str.replace(\\\\,);
的String [] = ARR str.split(U);
字符串文本=;
的for(int i = 1; I< arr.length;我++){
INT hexVal =的Integer.parseInt(ARR [I],16);
文字+ =(char)的hexVal;
}
或本
textview.setText(Html.from(StringEscapeUtils.unescapeJava(UNI code))); //此方法
有关更多:看到这个如何使用UNI code在Android的资源?
<一个href=\"http://stackoverflow.com/questions/11145681/how-to-convert-a-string-with-uni$c$c-encoding-to-a-string-of-letters\">How与统一code编码字符串转换为字母串
I am calling an API and receiving the response in both English and Urdu. The response is stored in a string and the urdu part shows character text like "/u024/".
I have been implementing this code set which is giving same result for as before for urdu characters. Kindly if anyone can help me out on this
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);
Your response in Unicode, try this
TextView tv=(TextView)findViewById(R.id.textViewmyView);
final Typeface tf = Typeface.createFromAsset(this.getAssets(),"asunaskh.ttf");
tv.setTypeface(tf);
tv.setText(Html.fromHtml(yourText);
add this if above doesn't work
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;
}
or this
textview.setText(Html.from(StringEscapeUtils.unescapeJava(unicode))); //this method
for more : see this How to use unicode in Android resource?
How to convert a string with Unicode encoding to a string of letters
这篇关于解码乌尔都语codeS Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!