diff options
-rw-r--r-- | toys/posix/expand.c | 2 | ||||
-rw-r--r-- | toys/posix/file.c | 2 | ||||
-rw-r--r-- | toys/posix/paste.c | 3 | ||||
-rw-r--r-- | toys/posix/wc.c | 1 |
4 files changed, 3 insertions, 5 deletions
diff --git a/toys/posix/expand.c b/toys/posix/expand.c index a25848ad..d4914ab5 100644 --- a/toys/posix/expand.c +++ b/toys/posix/expand.c @@ -49,7 +49,7 @@ static void do_expand(int fd, char *name) if (CFG_TOYBOX_I18N) { wchar_t blah; - width = mbrtowc(&blah, toybuf+i, len-i, 0); + width = utf8towc(&blah, toybuf+i, len-i); if (width > 1) { if (width != fwrite(toybuf+i, width, 1, stdout)) perror_exit("stdout"); diff --git a/toys/posix/file.c b/toys/posix/file.c index 658708cb..9958d044 100644 --- a/toys/posix/file.c +++ b/toys/posix/file.c @@ -267,7 +267,7 @@ static void do_regular_file(int fd, char *name, struct stat *sb) } else for (i = 0; i<len; ++i) { if (!(isprint(toybuf[i]) || isspace(toybuf[i]))) { wchar_t wc; - if ((bytes = mbrtowc(&wc, s+i, len-i, 0))>0 && wcwidth(wc)>=0) { + if ((bytes = utf8towc(&wc, s+i, len-i))>0 && wcwidth(wc)>=0) { i += bytes-1; if (!what) what = "UTF-8 text"; } else { diff --git a/toys/posix/paste.c b/toys/posix/paste.c index 42e6a287..ea04f02e 100644 --- a/toys/posix/paste.c +++ b/toys/posix/paste.c @@ -42,7 +42,6 @@ static void paste_files(void) // Start of each line/file resets delimiter cycle dpos = TT.d; - mbtowc(0, 0, 0); for (i = any = dcount = dlen = 0; seq || i<TT.files; i++) { size_t blen; @@ -84,7 +83,7 @@ static void paste_files(void) } } } else { - while (0<(dlen = mbtowc(&wc, dpos, 99))) { + while (0<(dlen = utf8towc(&wc, dpos, 99))) { dpos += dlen; if (!(dlen = wcwidth(wc))) continue; if (dlen<0) dpos = dstr+1; diff --git a/toys/posix/wc.c b/toys/posix/wc.c index 96ff9788..69c5f382 100644 --- a/toys/posix/wc.c +++ b/toys/posix/wc.c @@ -79,7 +79,6 @@ static void do_wc(int fd, char *name) wchar_t wchar; // next wide size, don't count invalid, fetch more data if necessary - clen = mbrtowc(&wchar, toybuf+pos, len-pos, 0); clen = utf8towc(&wchar, toybuf+pos, len-pos); if (clen == -1) continue; if (clen == -2 && !done) break; |