从收到的字符串的Andr​​oid UTF8编码 [英] android UTF8 encoding from received string

查看:155
本文介绍了从收到的字符串的Andr​​oid UTF8编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个字符串,它是无法正常连接codeD一样的myString%201,其中必须的myString 1我怎么会取代所有的字符可能是PTED为UTF8间$ P $?我读很多帖子,但不是一个完整的解决方案。请注意,字符串是已经连接codeD错了,我不是问怎么EN code字符序列。我前几天问同样的问题,为iOS和得到解决使用stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding谢谢

I am receiving a string that is not properly encoded like "mystring%201, where must be "mystring 1". How could I replace all characters that could be interpreted as UTF8? I read a lot of posts but not a full solution. Please note that string is already encoded wrong and I am not asking about how to encode char sequence. I asked same issue for iOS few days ago and was solved using stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding. Thank you.

IOS UTF8编码

ios UTF8 encoding from nsstring

推荐答案

您应该能够使用的 URLDe coder.de code()功能,如:

You should be able to use the URLDecoder.decode() function, like this:

String s = URLDecoder.decode(myString, "UTF-8");

此处了解详情:<一href=\"http://stackoverflow.com/questions/896721/urlen$c$cr-en$c$c-urlde$c$cr-de$c$c-in-java-android\">URLEn$c$cr EN code / URLDe codeR德code在Java(Android版)

这篇关于从收到的字符串的Andr​​oid UTF8编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆