CString, Strings encodings?

I am trying to get the fastest performance I can in writing mixed binary numeric and textual data to a memoryblock . To that end I am using a Pointer…

the docs said that Ptr.String existed and wrote code against the docs but then found it was not really supported. So then I thought maybe I could use Ptr.CString… That of course stops writing or reading at a null byte… I think that would not be an issue for UTF8, but can other multi-byte encodings include null bytes in them as part of the text or would it be safe to use ptr.CString with all encodings?


yes they can
esp utf-16 where every char is effectively 2 bytes and you may have piles of null bytes

Would using CString be OK at least for UTF8?
Googling, it looks like it legally could contain a 0 byte, but as it means Null, I don’t see a reason it would be in textual data.

  • Karen

I dont believe UTF-8 byte sequences include nulls anywhere even for multi byte sequences