| 风信Java论坛 ›› javascript/html/css 讨论交流中心 ›› [转]escape,encodeURI,encodeURIComponent 编码函数用法详解 | 登录 -> 注册 |
|
1F [转]escape,encodeURI,encodeURIComponent 编码函数用法详解 唧唧 Post by : 2008-07-03 02:35:15.0
通过ajax进行传递参数的时候,以下的函数是应用于编码方面,为了防止乱码,仔细研究下面的方法吧。 escape 方法 function escape(charString : String) : String 字符值大于 255 的字符以 %uxxxx 格式存储。 注意 escape 方法不能用来对“统一资源标识符”(URI) 进行编码。对其编码应使用 encodeURI 和 encodeURIComponent 方法。 请参见 适用于:Global 对象 encodeURI 方法 function encodeURI(URIString : String) : String 要求 请参见 适用于:Global 对象 encodeURIComponent 方法 function encodeURIComponent(encodedURIString : String) : String 要求 请参见 适用于:Global 对象 unescape 方法 function unescape(charString : String) : String 以 %uxxxx 格式(Unicode 字符)编码的字符用十六进制编码 xxxx 的 Unicode 字符代替。 注意 unescape 方法不应用于解码“统一资源标识符”(URI)。请改用 decodeURI 和 decodeURIComponent 方法。 请参见 适用于:Global 对象 decodeURI 方法 function decodeURI(URIstring : String) : String decodeURI 方法返回一个字符串值。 如果 URIString 无效,将发生 URIError。 要求 请参见 适用于:Global 对象 decodeURIComponent 方法 function decodeURIComponent(encodedURIString : String) : String 备注 如果 encodedURIString 无效,则将产生 URIError。 要求 请参见 适用于:Global 对象 |
| 风信Java论坛 ›› javascript/html/css 讨论交流中心 ›› [转]escape,encodeURI,encodeURIComponent 编码函数用法详解 | 登录 -> 注册 |