Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Android中的rawurlencode等价物_Php_Android_Urlencode_Url Encoding - Fatal编程技术网

Php Android中的rawurlencode等价物

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

我的PHP代码字符串中的
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