public class URLEncoder extends Object
application/x-www-form-urlencoded
MIME格式的静态方法。关于HTML表单编码的更多信息,查阅HTML
specification。
在对字符串进行编码时,下列规则适用:
a
”通过“z
”、“A
”通过“Z
”和“0
”通过“9
”保持不变。.
”、“-
”、“*
”、和“_
”保持不变。+
”。例如使用UTF-8编码格式的字符串的字符串ü@ foo bar”会转化为“+字符串+ % % % C3前40foo吧”因为在UTF-8字符编码为字节ü两C3(HEX)和BC(HEX),和字符编码为一个@字节40(HEX)。
@Deprecated public static String encode(String s)
x-www-form-urlencoded
格式字符串。该方法使用该平台的默认编码为编码方案,以获得不安全字符的字节数。
s
-
String
要翻译。
String
。
public static String encode(String s, String enc) throws UnsupportedEncodingException
application/x-www-form-urlencoded
格式字符串使用一个特定的编码方案。此方法使用所提供的编码方案以获取不安全字符的字节数。
注:万维网联盟推荐的国家应该使用UTF-8。不这样做可能会引入不兼容。
s
-
String
要翻译。
enc
-支持的
character encoding名称。
String
。
UnsupportedEncodingException
-如果指定的编码不支持
URLDecoder.decode(java.lang.String, java.lang.String)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.