1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-14 09:37:34 -05:00

New centralised helper function dup_mb_to_wc().

PuTTY's main mb_to_wc() function is all very well for embedding in
fiddly data pipelines, but for the simple job of turning a C string
into a C wide string, really I want something much more like
dupprintf. So here is one.

I've had to put it in a new separate source file miscucs.c rather than
throwing it into misc.c, because misc.c is linked into tools that
don't also include a module providing the internal Unicode API (winucs
or uxucs). The new miscucs.c appears only in Unicode-using tools.

(cherry picked from commit 7762d71226)
This commit is contained in:
Simon Tatham
2015-07-27 20:06:02 +01:00
parent 557a99e78e
commit 1f7f422d7a
3 changed files with 39 additions and 2 deletions

9
misc.h
View File

@ -39,6 +39,15 @@ char *dupprintf(const char *fmt, ...)
char *dupvprintf(const char *fmt, va_list ap);
void burnstr(char *string);
/* String-to-Unicode converters that auto-allocate the destination and
* work around the rather deficient interface of mb_to_wc.
*
* These actually live in miscucs.c, not misc.c (the distinction being
* that the former is only linked into tools that also have the main
* Unicode support). */
wchar_t *dup_mb_to_wc_c(int codepage, int flags, const char *string, int len);
wchar_t *dup_mb_to_wc(int codepage, int flags, const char *string);
int toint(unsigned);
char *fgetline(FILE *fp);