某些字符比其他字符占用更多字节吗? [英] Do certain characters take more bytes than others?

查看:241
本文介绍了某些字符比其他字符占用更多字节吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是很有经验的较低级别的东西,如一个字符的多少字节。我尝试找出一个字符是否等于一个字节,但没有成功。

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.

当前分隔符为#。

推荐答案

这取决于使用什么字符编码来转换字符和字节

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-8中,每个字符使用1到4个字节。

  • 在ISO 2022中,更复杂

US-ASCII字符(只有# UTF-8,这是允许多字节字符的最流行的编码。

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.

这篇关于某些字符比其他字符占用更多字节吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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