How to Decode String in Android?

百般思念 提交于 2019-12-13 18:43:39

问题


I have a parser module in my application which will parse the response from a webservice and give the tag value. The tag value contains some special characters like ® etc. The problem is I could not decode the special characters to normal string. please find the sample response string below,

Apple® iPad™ Case

Please some body help me to solve this problem.


回答1:


Just Use String result = URLDecoder.decode(string, "UTF-8");

Or use this

byte[] data = Base64.decode(base64, Base64.DEFAULT);
String text = new String(data, "UTF-8");



回答2:


Use something like this

String decodedString = URLDecoder.decode(your string, "UTF-8");


来源:https://stackoverflow.com/questions/7089348/how-to-decode-string-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!