Introduce wcs2string_callback

This is like wcs2string, but instead of returning a std::string, it invokes
a user-supplied function with each converted character.

The idea is to allow interleaved conversion and output.
This commit is contained in:
ridiculousfish
2020-07-29 17:16:51 -07:00
parent c9b42c6f1f
commit a0cb23bea5
3 changed files with 52 additions and 29 deletions

View File

@@ -8,6 +8,7 @@
#include <locale>
#include "common.h"
#include "flog.h"
wcstring_range wcstring_tok(wcstring &str, const wcstring &needle, wcstring_range last) {
using size_type = wcstring::size_type;
@@ -196,3 +197,7 @@ wcstring join_strings(const wcstring_list_t &vals, wchar_t sep) {
}
return result;
}
void wcs2string_bad_char(wchar_t wc) {
FLOGF(char_encoding, L"Wide character U+%4X has no narrow representation", wc);
}