如何在 ActionScript 3 套接字连接中设置字符编码?
在询问“某些字符是否比其他字符占用更多字节?”,我发现在 Actionscript / Flex 3 中使用套接字连接接收和发送数据时需要设置字符编码集。
现在我一直在尝试找出如何做到这一点,但是没有似乎有这样的财产可用。 有什么特殊的方法可以做到这一点吗?
After asking "Do certain characters take more bytes than others?", I figured out that I'd need to set the character encoding set when receiving and sending data with a socket connection in Actionscript / Flex 3.
Now I've been trying to find out how to do this, however there doesn't seem to be such property available. Is there any special way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,Flash 仅支持 Unicode...尽管可以选择使用操作系统的代码页 System.useCodePage。 但这取决于用户的操作系统和语言,除非您确切知道自己在做什么,否则不建议这样做。
至于每个字符使用较少的字节,我知道字母数字字符在 UTF-8 中仅使用一个字节。
干杯...
As far as I know, Flash supports only Unicode... though there is the option to use the OS's code page with System.useCodePage. But it will depend on the user's OS and language, and is not recommended unless you know exactly what you are doing.
As for using less bytes per character, I understand that alphanumeric characters use only one byte in UTF-8 .
Cheers...
flash.net.Socket 类是一个二进制文件输入/输出类。 您无需指定套接字本身的编码,因为您对套接字中的数据具有低级访问权限。
您正在寻找的是 套接字: :readMultiByte 方法用于从不同的字符集中读取字符串。
同样,使用 Socket::writeMultiByte 用于从特定字符集写入字符串。
The flash.net.Socket class is a binary input/output class. You do not specify the encoding for the socket itself because you have low-level access to the data in the socket.
What you're looking for is the Socket::readMultiByte method for reading strings from different character sets.
Likewise, use Socket::writeMultiByte for writing strings from a specific character set.