From 2265dc5c5b81e8411bc25e87b3fbecae5b7d57e6 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 19 Jul 2012 17:03:15 +0000 Subject: [PATCH] Silly of me to overlook it: another obvious way you might like to specify characters to 'confuse' is to just put them on the command line in the system multibyte encoding! In a UTF-8 terminal environment this may very well be the easiest thing. git-svn-id: svn://svn.tartarus.org/sgt/charset@9584 cda61777-01e9-0310-a592-d414129be87e --- confuse.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/confuse.c b/confuse.c index 207c5b9..21005cf 100644 --- a/confuse.c +++ b/confuse.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "charset.h" @@ -24,6 +25,8 @@ int main(int argc, char **argv) int i, j, k, cs; const char *sep; + setlocale(LC_ALL, ""); + chars = malloc(argc * sizeof(wchar_t)); if (!chars) { fprintf(stderr, "out of memory\n"); @@ -37,6 +40,7 @@ int main(int argc, char **argv) char *orig = p; char *end; int base = 16, semi_ok = 0; + wchar_t ch; if ((p[0] == 'U' || p[0] == 'u') && (p[1] == '-' || p[1] == '+')) { @@ -50,6 +54,9 @@ int main(int argc, char **argv) else base = 10; semi_ok = 1; + } else if (mbtowc(&ch, p, strlen(p)) == strlen(p)) { + chars[nchars++] = ch; + continue; } chars[nchars++] = strtoul(p, &end, base); -- 2.11.0