How to write a std::string to a UTF-8 text file
The only way UTF-8 affects std::string is that size(), length(), and all the indices are measured in bytes, not characters. And, as sbi points out, incrementing the iterator provided by std::string will step forward by byte, not by character, so it can actually point into the middle of a multibyte UTF-8 codepoint. There’s no UTF-8-aware …