Skip to content

Commit

Permalink
Fix narrow_to_wide_c (ANDROID)
Browse files Browse the repository at this point in the history
* Ensure converted string is NUL terminated
* Restore logic to that used prior to 9e2a9b5
  • Loading branch information
Zeno- committed Mar 2, 2015
1 parent 773aa8c commit aefe807
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/util/string.cpp
Expand Up @@ -83,16 +83,18 @@ const wchar_t *narrow_to_wide_c(const char *mbs)
size_t mbl = strlen(mbs);
wchar_t *wcs = new wchar_t[mbl + 1];

for (size_t i = 0; i < mbl; i++) {
size_t i, dest_i = 0;
for (i = 0; i < mbl; i++) {
if (((unsigned char) mbs[i] > 31) &&
((unsigned char) mbs[i] < 127)) {
wcs[i] = wide_chars[(unsigned char) mbs[i] - 32];
wcs[dest_i++] = wide_chars[(unsigned char) mbs[i] - 32];
}
//handle newline
else if (mbs[i] == '\n') {
wcs[i] = L'\n';
wcs[dest_i++] = L'\n';
}
}
wcs[dest_i] = '\0';

return wcs;
}
Expand Down

0 comments on commit aefe807

Please sign in to comment.