Commit 7375cdd8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix MB2MB and use it

parent 8353a94d
...@@ -62,15 +62,14 @@ ...@@ -62,15 +62,14 @@
# define ASSUME_UTF8 1 # define ASSUME_UTF8 1
#endif #endif
#ifndef ASSUME_UTF8 #if defined (ASSUME_UTF8)
# if defined (HAVE_ICONV) /* Cool */
/* libiconv is more powerful than Win32 API (it has translit) */ #elif defined (WIN32) || defined (UNDER_CE)
# define USE_ICONV 1
# elif defined (WIN32) || defined (UNDER_CE)
# define USE_MB2MB 1 # define USE_MB2MB 1
# else #elif defined (HAVE_ICONV)
# define USE_ICONV 1
#else
# error No UTF8 charset conversion implemented on this platform! # error No UTF8 charset conversion implemented on this platform!
# endif
#endif #endif
typedef struct locale_data_t typedef struct locale_data_t
...@@ -192,17 +191,14 @@ static char *locale_fast (const char *string, locale_data_t *p) ...@@ -192,17 +191,14 @@ static char *locale_fast (const char *string, locale_data_t *p)
if (string == NULL) if (string == NULL)
return NULL; return NULL;
len = MultiByteToWideChar (p->fromCP, 0, string, -1, NULL, 0); len = 1 + MultiByteToWideChar (p->fromCP, 0, string, -1, NULL, 0);
if (len == 0)
return NULL;
wchar_t wide[len]; wchar_t wide[len];
MultiByteToWideChar (p->fromCP, 0, string, -1, wide, len); MultiByteToWideChar (p->fromCP, 0, string, -1, wide, len);
len = WideCharToMultiByte (p->toCP, 0, wide, -1, NULL, 0, NULL, NULL); len = 1 + WideCharToMultiByte (p->toCP, 0, wide, -1, NULL, 0, NULL, NULL);
if (len == 0)
return NULL;
out = malloc (len); out = malloc (len);
if (out == NULL)
return NULL;
WideCharToMultiByte (p->toCP, 0, wide, -1, out, len, NULL, NULL); WideCharToMultiByte (p->toCP, 0, wide, -1, out, len, NULL, NULL);
return out; return out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment