flex的http URL转码与解码

private function httpEncoding(param:String):String{    //转码 
    return encodeURIComponent(param); 


private function openSelfStr(deleteStr:String):String{    //解码 
    return decodeURIComponent(deleteStr); 





------------------------------------------------------------------------------------------------------- 
在URL后面加?传递的参数里有中文的时候,后台就取不到值。这时就需要对其进行转码 

Flex中转码的函数:escape,encodeURI,encodeURIComponent 

Flex中相应解码函数:unescape,decodeURI,decodeURIComponent 



一、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 

posted @ 2015-01-30 22:49  coolsundy  阅读(358)  评论(0编辑  收藏  举报