1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 19:41:01 -05:00

New utility function: decode_utf8_to_wide_string.

We already had encode_wide_string_as_utf8, which treats the wide
string as UTF-16 or UTF-32 as appropriate to the size of wchar_t. I'm
about to need the inverse function, and was surprised that it didn't
already exist (even though enough component parts did to make it easy).
This commit is contained in:
Simon Tatham
2023-05-29 13:27:16 +01:00
parent 36db93748e
commit 392be3e494
3 changed files with 40 additions and 0 deletions

4
misc.h
View File

@ -256,6 +256,10 @@ unsigned smemeq(const void *av, const void *bv, size_t len);
* encoded in UTF-16. */
char *encode_wide_string_as_utf8(const wchar_t *wstr);
/* Decode UTF-8 to a wide-character string, emitting UTF-16 surrogates
* if sizeof(wchar_t) == 2. */
wchar_t *decode_utf8_to_wide_string(const char *ustr);
/* Decode a single UTF-8 character. Returns U+FFFD for any of the
* illegal cases. If the source is empty, returns L'\0' (and sets the
* error indicator on the source, of course). */