Luar's Flash Playground:AS1/2 escape()和AS3 escape() 是不同
AS1/2 escape()和AS3 escape() 是不同 (19-01-2007)

在英文開發環境,未必容易察覺,因為AS1/2 escape()和AS3 escape() return相同結果,但是在double-byte文字,AS3 escape()終於跟JavaScript的做法相同,如果你要以前AS1/2的格式,你要用encodeURI()或者encodeURIComponent()。

ActionScript 1/2

var a:String = "香港:";
trace(escape(a)); // %E9%A6%99%E6%B8%AF%3A

ActionScript 3

var a:String = "香港:";
trace(escape(a)); // %u9999%u6E2F%3A
trace(encodeURI(a)); // %E9%A6%99%E6%B8%AF:
trace(encodeURIComponent(a)); // %E9%A6%99%E6%B8%AF%3A

JavaScript

var a = "香港:";
alert(escape(a)); // %u9999%u6E2F%3A
alert(encodeURI(a)); // %E9%A6%99%E6%B8%AF:
alert(encodeURIComponent(a)); // %E9%A6%99%E6%B8%AF%3A

本文章由發表。
意見
"; print "沒有意見。
 "; } ?>
  • escape()函数是干吗用的?搞乱码?

    由lele於24-01-2007發表

  • useful

    iu99於04-02-2007發表

  • escape 函数
    escape(expression:String) : String

    将参数转换为字符串,并以 URL 编码格式对其进行编码,在这种格式中,所有非字母数字的字符都替换为 % 十六进制序列。当用于 URL 编码的字符串中时,百分号 (%) 用于引入转义符,不与模运算符 (%) 等效。


    lele网友不要自己不先看看就随便说嘛

    helen於10-02-2007發表

同組文章