Hi, Peter, On Mon, Dec 22, 2025 at 1:55 AM Peter J. Holzer <[email protected]> wrote: > > On 2025-12-21 17:30:38 -0800, Igor Korot wrote: > > On Sun, Dec 21, 2025 at 1:19 PM Peter J. Holzer <[email protected]> wrote: > > > As I see it, Igor has two options: > > > > > > 1) Send UTF8. wcstombs is the wrong tool for this, since it uses the > > > current locale which is obviously not using UTF-8. I don't program in > > > C++, but I'm pretty sure there is a portable way to encode a string > > > in UTF-8. > [...] > > > I think 1) is the better strategy, but them I've been a UTF-8 fan-boy > > > for over 30 years ;-). > > > > Maybe all I need is something like this: > > > > convert(char *dest, const std::wstring src) > > { > > const wchar_t *temp = src.c_str(); > > while( *dest ) > > { > > dest++; > > } > > while( *temp ) > > { > > *dest = *temp; > > dest++; > > temp++; > > } > > *dest++ = '\0'; > > *dest = '\0'; > > } > > > > ? > > I hope your compiler complains loudly about that code. You can't just > assign a wchar_t to a char and expect it to do anything sensible.
At least MSVC 2017 did not. However, trying didn't solve it. Same error. > > A short search points to std::wstring_convert, but that has been > deprecated in C++17, and it's not obvious to me what the replacement is. > > There is always ICU, of course, but that feels like cracking a nut with > a sledgehammer. I think ICU IS a replacement for wstring_comvert. Will check it. > > Personally, I might roll my own if an hour of googling doesn't turn up > anything promising (UTF-8 encoding is quite simple), but that shouldn't > be necessary. > > > hjp > > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | [email protected] | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!"
