diff options
author | Rob Landley <rob@landley.net> | 2012-12-01 18:30:20 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-12-01 18:30:20 -0600 |
commit | ddd4685b3482dfe4bea9d72fee2b47bddde42697 (patch) | |
tree | 77d983dd61dc852eaeaca2d4dc4f51da897c23cd | |
parent | e0cc81ef759b22e79c516bf5dbc6207c45447e4f (diff) | |
download | toybox-ddd4685b3482dfe4bea9d72fee2b47bddde42697.tar.gz |
First guess at what internationalization support for expand would look like.
-rw-r--r-- | toys/posix/expand.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/toys/posix/expand.c b/toys/posix/expand.c index d1b82a7c..789364bb 100644 --- a/toys/posix/expand.c +++ b/toys/posix/expand.c @@ -45,7 +45,22 @@ static void expand_file(int fd, char *name) 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); |