Detailed explanation of Android UTF-8 transcoding example
In the project, you may encounter the situation where there is Chinese in the url. At this time, we may need to encode the url.
mport ; import ; import ; public class UTFTest { public static void main(String[] args) { String str = "Test character conversion hello word"; //The default environment is already UTF-8 encoding try { String strGBK = (str, "GBK"); (strGBK); String strUTF8 = (str, "UTF-8"); (strUTF8); } catch (UnsupportedEncodingException e) { (); } } }
Encode through the encode method of URLEncoder and decode method.
Thank you for reading, I hope it can help you. Thank you for your support for this site!