From 98b37e3e0d4d0bcea4d0a202f8519a39163b7493 Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Wed, 11 Feb 2015 02:27:43 -0500 Subject: Fix Android build of narrow_to_wide --- src/util/string.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/util/string.cpp b/src/util/string.cpp index b4908d62d..c18e58613 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -62,20 +62,21 @@ int wctomb(char *s, wchar_t wc) int mbtowc(wchar_t *pwc, const char *s, size_t n) { - wchar_t *intermediate = narrow_to_wide(s); + const wchar_t *tmp = narrow_to_wide_c(s); - if (intermediate.length() > 0) { - *pwc = intermediate[0]; + if (tmp[0] != '\0') { + *pwc = tmp[0]; return 1; } else { return -1; } } + // You must free the returned string! const wchar_t *narrow_to_wide_c(const char *mbs) { size_t mbl = strlen(mbs); - wchar_t wcs = new wchar_t[mbl + 1]; + wchar_t *wcs = new wchar_t[mbl + 1]; for (size_t i = 0; i < mbl; i++) { if (((unsigned char) mbs[i] > 31) && -- cgit v1.2.3