Open abuneri opened 1 year ago
Can also alternatively just use https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar on windows to convert the UTF-8 to UTF-16 (wide chars) and then print to std::wcout
/std::wcerr
On modern linux/macOS platforms where UTF-8 is the default encoding, we can use the existing standard library stream facilities; however, on Windows we would have to convert everything to wide characters (UTF-16) to use the standard library. The inclusion of
auc::u8print()
would be an abstraction to handle the special case on windows where we can use the win32 API (https://stackoverflow.com/a/10882801, https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode?view=msvc-170) to print our UTF-8 data directly instead of having to transcode it to wide chars.auc::u8print()
should also allow users to specify where the data is going (for starts, just supportstdout
andstderr
) where the default would bestdout
.We should also potentially add a
auc::u8fprint()
to our UTF-8 classes can be output directly to files (this can be easily validated via round trip write-read-validate testing)If/when we ever move to C++23 then this print facility can be removed (API will most likely still exist just the implementation details will change) and replaced with
std::print
facilities instead.