我有一个字符串的 UTF8
。
我需要得到它的大小。 (字节)
I need to get its size. ( bytes)
总是做它 X2
? //我的意思是乘以2 的
有没有.NET功能呢?
is there any .net function for this ?
P.S。
我要问这个问题监守我最新的question ...我需要(在mempry映射文件)calc下的串偏移(UTF8) - 从另一个进程。的
im asking this question becuase of my latest question ...I need ( in mempry mapped file) to calc the offset of a string ( utf8 ) - from another process..
没有,它并不总是根据实际内容X2为UTF-8和变化。为ASCII字符它是1字节,但也可以写入多个字节为大$ C $的c-点值。你想:
No, it is not always x2 for UTF-8 and changes based on the actual contents. For ASCII characters it is 1 byte, but can go into several bytes for large code-point values. You want:
string s = // your string
int len = Encoding.UTF8.GetByteCount(s);
上一篇:如何在画布上的图像加载从JSON对象的图片?画布、图像、加载、对象
下一篇:字符串,字符串>到转换字典和其中的最佳方式;进入单聚集字符串重新presentation?字符串、字典、方式、presentation