将字符串转换为ASCII代码并返回Flash

Rob*_*cks 1 string flash ascii actionscript-3

在AS2中,您具有功能ord(),chr()并且专门将ASCII代码转换为其等效字符串.

但是在AS3中,String.charCodeAt()String.fromCharCode()使用Unicode值.

有没有办法将字符串字符转换为ASCII等效字符并返回?

Rob*_*cks 12

好吧,我找到了答案,而且很奇怪.

通常所谓的"Unicode"函数似乎也适用于ASCII值.

trace(String.fromCharCode(65))  // "A"
trace(("A").charCodeAt(0))      // 65
Run Code Online (Sandbox Code Playgroud)