I have a string of utf8
.
I need to get its size. ( bytes)
Does it always x2
? // I mean multiply by 2
is there any .net function for this ?
p.s.
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..
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With