Changeset View
Changeset View
Standalone View
Standalone View
b/src/w32-gettext.c
Context not available. | |||||
} | } | ||||
/* Return a malloced string encoded in UTF-8 from the wide char input | /* Return a malloced string encoded in the native console codepage | ||||
string STRING. Caller must free this value. On failure returns | from the wide char input string STRING. | ||||
NULL. The result of calling this function with STRING set to NULL | Caller must free this value. On failure returns NULL. | ||||
The result of calling this function with STRING set to NULL | |||||
is not defined. */ | is not defined. */ | ||||
static char * | static char * | ||||
wchar_to_native (const wchar_t *string, size_t length, size_t *retlen) | wchar_to_native (const wchar_t *string, size_t length, size_t *retlen) | ||||
{ | { | ||||
int n; | int n; | ||||
char *result; | char *result; | ||||
unsigned int cpno = GetConsoleOutputCP (); | |||||
/* GetConsoleOutputCP returns the 8-Bit codepage that should be used | |||||
for console output. If the codepage is not returned we fall back | |||||
to the codepage GUI programs should use (CP_ACP). */ | |||||
if (!cpno) | |||||
cpno = GetACP (); | |||||
n = WideCharToMultiByte (CP_ACP, 0, string, length, NULL, 0, NULL, NULL); | n = WideCharToMultiByte (cpno, 0, string, length, NULL, 0, NULL, NULL); | ||||
if (n < 0 || (n+1) <= 0) | if (n < 0 || (n+1) <= 0) | ||||
return NULL; | return NULL; | ||||
Context not available. | |||||
if (!result) | if (!result) | ||||
return NULL; | return NULL; | ||||
n = WideCharToMultiByte (CP_ACP, 0, string, length, result, n, NULL, NULL); | n = WideCharToMultiByte (cpno, 0, string, length, result, n, NULL, NULL); | ||||
if (n < 0) | if (n < 0) | ||||
{ | { | ||||
jnlib_free (result); | jnlib_free (result); | ||||
Context not available. |