Android - How to Convert String to utf-8 in android

前端 未结 4 802
陌清茗
陌清茗 2020-12-17 21:14

I can\'t convert a String to UTF-8 in android. please help me!!

s1=URLEncoder.encode(\"臺北市\")

result : %EF%BF%BDO%EF%BF%BD_%EF%BF%BD%

4条回答
  •  有刺的猬
    2020-12-17 21:39

    In http://developer.android.com/reference/java/net/URLEncoder.html you can read that the you used is deprecated and that you should use static String encode(String s, String charsetName)

    So URLEncoder.encode("臺北市", "utf-8") should do the trick.

提交回复
热议问题