We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 773aa8c commit aefe807Copy full SHA for aefe807
src/util/string.cpp
@@ -83,16 +83,18 @@ const wchar_t *narrow_to_wide_c(const char *mbs)
83
size_t mbl = strlen(mbs);
84
wchar_t *wcs = new wchar_t[mbl + 1];
85
86
- for (size_t i = 0; i < mbl; i++) {
+ size_t i, dest_i = 0;
87
+ for (i = 0; i < mbl; i++) {
88
if (((unsigned char) mbs[i] > 31) &&
89
((unsigned char) mbs[i] < 127)) {
- wcs[i] = wide_chars[(unsigned char) mbs[i] - 32];
90
+ wcs[dest_i++] = wide_chars[(unsigned char) mbs[i] - 32];
91
}
92
//handle newline
93
else if (mbs[i] == '\n') {
- wcs[i] = L'\n';
94
+ wcs[dest_i++] = L'\n';
95
96
97
+ wcs[dest_i] = '\0';
98
99
return wcs;
100
0 commit comments