The goal of this project is to make a type that mirrors System.String
as much as practical. It should be a heapable, immutable, indexable, and pinnable type. The data may contain embedded null characters. When pinned, the pointer should represent a null-terminated UTF-8 string.
We should provide conversions between String
and Utf8String
, though due to the expense of conversion we should avoid these operations when possible. There are a few ways to avoid these, including:
- Adding
Utf8String
-based overloads to existing APIs likeConsole.WriteLine
,File.WriteAllText
, etc. - Adding
ToUtf8String
methods on existing types likeInt32
. - Implement utility classes like
Utf8StringBuilder
. - Not having implicit or explicit conversion operators that could perform expensive transcodings, but instead having constructor overloads or some other obvious "this may be expensive" mechanism.