Php Android中的rawurlencode等价物
我的PHP代码字符串中的Php Android中的rawurlencode等价物,php,android,urlencode,url-encoding,Php,Android,Urlencode,Url Encoding,我的PHP代码字符串中的rawurlencode($string)函数返回一个字符串。从android编码时,我需要相同的字符串。 我使用了以下代码: encoded_url = URLEncoder.encode(string,"UTF-8"); android和php的结果几乎相同,但android的结果在末尾附加了%0A。我搜索了它,发现%0A是换行符。如何删除此项,或者是否有更好的rawurlencode()等效项?使用 好问题,兄弟。。。希望你能尽快解决 public static
rawurlencode($string)
函数返回一个字符串。从android编码时,我需要相同的字符串。
我使用了以下代码:
encoded_url = URLEncoder.encode(string,"UTF-8");
android和php的结果几乎相同,但android的结果在末尾附加了%0A
。我搜索了它,发现%0A
是换行符。如何删除此项,或者是否有更好的rawurlencode()等效项?使用
好问题,兄弟。。。希望你能尽快解决
public static String encodeUri(String uri,
String encoding)
throws UnsupportedEncodingException
Encodes the given source URI into an encoded String. All various URI components are encoded according to their respective valid character sets.
Parameters:
uri - the URI to be encoded
encoding - the character encoding to encode to
Returns:
the encoded URI
Throws:
IllegalArgumentException - when the given uri parameter is not a valid URI
UnsupportedEncodingException - when the given encoding parameter is not supported