aui
aui copied to clipboard
Implement AStringView as AByteBufferView
Issues
While implementing AStringView I have encountered the following design issues:
- Should use char16_t instead of wchar_t because size of wchar_t differs on Windows and Linux, causing incompatibility.
- Since AString is a wchar_t storage, AStringView is expected to be a wchar_t storage too, which forces to use widechar string literals (
L""instead of""). - Construction of AString from const char* always performs expensive utf8 parsing.
Possible solutions
- Switch AString to basic char string and implement utf8 iterator, however text field and font rendering implementation may require a special 32-bit AString.
- Use AStringView only for substrings and trims.
- Implement string COW instead of AStringView
Existing solutions
- Qt, C#, Java, Kotlin use UTF-16 in their strings, also Qt implements copy on write (COW).
- GTK uses UTF-8.
Another possible solution: store a global std::unordered_map from const char* to const char16_t*.