mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 18:13:46 +01:00
Fix narrow_to_wide_c (ANDROID)
* Ensure converted string is NUL terminated * Restore logic to that used prior to 9e2a9b5
This commit is contained in:
parent
773aa8c57b
commit
aefe80769b
@ -83,16 +83,18 @@ const wchar_t *narrow_to_wide_c(const char *mbs)
|
|||||||
size_t mbl = strlen(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++) {
|
size_t i, dest_i = 0;
|
||||||
|
for (i = 0; i < mbl; i++) {
|
||||||
if (((unsigned char) mbs[i] > 31) &&
|
if (((unsigned char) mbs[i] > 31) &&
|
||||||
((unsigned char) mbs[i] < 127)) {
|
((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
|
//handle newline
|
||||||
else if (mbs[i] == '\n') {
|
else if (mbs[i] == '\n') {
|
||||||
wcs[i] = L'\n';
|
wcs[dest_i++] = L'\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
wcs[dest_i] = '\0';
|
||||||
|
|
||||||
return wcs;
|
return wcs;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user