在URL后面加?传递的参数里有中文的时候,后台就取不到值。这时就需要对其进行转码
Flex中转码的函数 :escape,encodeURI,encodeURIComponent
Flex中相应 解码函数 :unescape,decodeURI,decodeURIComponent
var url:String="http://202.197.108.65:8080/Flex/uploadmp3.jsp?musicname=" +encodeURIComponent(music_name.text)
+
"&singername="
+encodeURIComponent(singer_name.text);
一、escape 对 0-255 以外的 unicode 值进行编码时输出 %u**** 格式。
其它情况下
escape
,
encodeURI
,
encodeURIComponent
编码结果相同。
二、 encodeURIComponent 是将中文、韩文等特殊字符转换成 utf-8 格式的 url 编码,所以如果给后台传递参数需要使用 encodeURIComponent 时需要后台解码对 utf-8 支持
PS:
escape
不编码字符有
69
个:
*
,
+
,
-
,
.
,
/
,
@
,
_
,
0-9
,
a-z
,
A-Z
encodeURI 不编码字符有 82 个: ! , # , $ , & , ' , ( , ) , * , + , , , - , . , / , : , ; , = , ? , @ , _ , ~ , 0-9 , a-z , A-Z
encodeURIComponent 不编码字符有 71 个: ! , ' , ( , ) , * , - , . , _ , ~ , 0-9 , a-z , A-Z