问题描述
我对较低级别的事物(例如字符有多少个字节)不是很有经验.我试图找出一个字符是否等于一个字节,但没有成功.
I'm not very experienced with lower level things such as howmany bytes a character is. I tried finding out if one character equals one byte, but without success.
我需要设置一个用于服务器和客户端之间的套接字连接的分隔符.此分隔符必须尽可能小(以字节为单位),以最大限度地减少带宽.
I need to set a delimiter used for socket connections between a server and clients. This delimiter has to be as small (in bytes) as possible, to minimize bandwidth.
当前的分隔符是#".使用其他分隔符会减少我的带宽吗?
The current delimiter is "#". Would getting an other delimiter decrease my bandwidth?
推荐答案
这取决于你使用什么字符编码在字符和字节之间进行转换(这根本不是一回事):
It depends on what character encoding you use to translate between characters and bytes (which are not at all the same thing):
- 在 ASCII 或 ISO 8859 中,每个字符由一个字节表示
- 在 UTF-32 中,每个字符由 4 个字节表示
- 在 UTF-8 中,每个字符使用 1 到 4 个字节
- 在 ISO 2022 中,情况要复杂得多
US-ASCII 字符(其中 # 是其中之一)在 UTF-8 中仅占用 1 个字节,这是最流行的允许多字节字符的编码.
US-ASCII characters (of whcich # is one) will take only 1 byte in UTF-8, which is the most popular encoding that allows multibyte characters.
这篇关于某些字符是否比其他字符占用更多字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!