Mercurial > hg > toybox
changeset 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 | 76e7bf56b2e6 |
children | 0cd93dd23b8d |
files | toys/posix/expand.c |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
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);