如何在actionscript 3套接字连接中设置字符编码? [英] Howto set character encoding in actionscript 3 socket connections?

查看:262
本文介绍了如何在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?

推荐答案

flash.net.Socket 类是一个二进制输入/输出类。您不必为套接字本身指定编码,因为您可以对套接字中的数据进行低级访问。

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.

您正在查找的是 Socket :: readMultiByte 方法读取字符串不同的字符集。

What you're looking for is the Socket::readMultiByte method for reading strings from different character sets.

public function readMultiByte(length:uint, charSet:String):String

同样,使用 Socket :: writeMultiByte 用于从特定字符集写入字符串。

Likewise, use Socket::writeMultiByte for writing strings from a specific character set.

public function writeMultiByte(value:String, charSet:String):void

这篇关于如何在actionscript 3套接字连接中设置字符编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆