Mercurial > hg > toybox
diff toys/posix/expand.c @ 732:45dbb4a5a3bc
First guess at what internationalization support for expand would look like.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 01 Dec 2012 18:30:20 -0600 |
parents | e7c14db739c1 |
children | 6cc69be43c42 |
line wrap: on
line diff
--- a/toys/posix/expand.c Sat Dec 01 18:27:37 2012 -0600 +++ b/toys/posix/expand.c Sat Dec 01 18:30:20 2012 -0600 @@ -45,7 +45,22 @@ if (!len) break; for (i=0; i<len; i++) { int width = 1; - char c = toybuf[i]; + char c; + + if (CFG_TOYBOX_I18N) { + wchar_t blah; + + width = mbrtowc(&blah, toybuf+i, len-i, 0); + if (width > 1) { + if (width != fwrite(toybuf+i, width, 1, stdout)) + perror_exit("stdout"); + i += width-1; + x++; + continue; + } else if (width == -2) break; + else if (width == -1) continue; + } + c = toybuf[i]; if (c != '\t') { if (EOF == putc(c, stdout)) perror_exit(0);