If you are printing to the console/terminal on Windows, then that is exactly the problem.
I have never failed by converting to UTF-16 and printing using the
Windows console I/O routines.
It is why I wrote
https://github.com/Duthomhas/utf8_console
You can look at the (shockingly simple) magic that makes UTF-8 I/O work by examining the
utf8_console.cpp file:
•
duthomhas::utf8::console::Input streambuf for console input
•
duthomhas::utf8::console::Output streambuf for console output
•
duthomhas::utf8::console::initialize() sets everything up for you
The rest of the file is just to hijack
main() and fix the command-line arguments to UTF-8 as well, but you can ignore that.
The point is you can use similar magic to hijack
cout, etc to properly format your stuff.
(I am considering updating utf8_console to enable alternate methods for fixing
main()’s arguments.)