Not all parameters need to be encoded. Using URLEncoder是一种解决方式,但是并不是必须的选择。 但是如果你的参数中带有URI保留字,那你必须要使用URLEncoder。比如你的参数中带有/&?=...这类保留字,如果你不编码那解析URL to solve Chinese garbled characters is definitely not the result you expect. RFC 3986 2.2. Reserved Characters
In the Android code, I use android.net.Uri.encode(). If I am not sure whether there are special characters in the parameters, I just add them. It is not complicated.
Not all parameters need to be encoded. Using
URLEncoder
是一种解决方式,但是并不是必须的选择。但是如果你的参数中带有
URI
保留字,那你必须要使用URLEncoder
。比如你的参数中带有/&?=
...这类保留字,如果你不编码那解析URL
to solve Chinese garbled characters is definitely not the result you expect.RFC 3986 2.2. Reserved Characters
Prevent Chinese garbled characters, you can use it or not
The browser will automatically do URLEncoder.encode once, no need to manually URLEncoder.encode
In the Android code, I use android.net.Uri.encode(). If I am not sure whether there are special characters in the parameters, I just add them. It is not complicated.