mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-18 03:20:59 -05:00
Add a manual single-char UTF-8 decoder.
This parallels encode_utf8 which we already had. Decoding is more fraught with perils than encoding, so I've also included a small test program.
This commit is contained in:
11
misc.h
11
misc.h
@ -221,6 +221,17 @@ size_t encode_utf8(void *output, unsigned long ch);
|
||||
* encoded in UTF-16. */
|
||||
char *encode_wide_string_as_utf8(const wchar_t *wstr);
|
||||
|
||||
/* Decode a single UTF-8 character. Returns U+FFFD for any of the
|
||||
* illegal cases. */
|
||||
unsigned long decode_utf8(const char **utf8);
|
||||
|
||||
/* Decode a single UTF-8 character to an output buffer of the
|
||||
* platform's wchar_t. May write a pair of surrogates if
|
||||
* sizeof(wchar_t) == 2, assuming that in that case the wide string is
|
||||
* encoded in UTF-16. Otherwise, writes one character. Returns the
|
||||
* number written. */
|
||||
size_t decode_utf8_to_wchar(const char **utf8, wchar_t *out);
|
||||
|
||||
/* Write a string out in C string-literal format. */
|
||||
void write_c_string_literal(FILE *fp, ptrlen str);
|
||||
|
||||
|
Reference in New Issue
Block a user