~mdw
/
sgt
/
charset
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Silly of me to overlook it: another obvious way you might like to
[sgt/charset]
/
confuse.c
diff --git
a/confuse.c
b/confuse.c
index
207c5b9
..
21005cf
100644
(file)
--- a/
confuse.c
+++ b/
confuse.c
@@
-11,6
+11,7
@@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <locale.h>
#include "charset.h"
#include "charset.h"
@@
-24,6
+25,8
@@
int main(int argc, char **argv)
int i, j, k, cs;
const char *sep;
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");
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;
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] == '+')) {
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
base = 10;
semi_ok = 1;
+ } else if (mbtowc(&ch, p, strlen(p)) == strlen(p)) {
+ chars[nchars++] = ch;
+ continue;
}
chars[nchars++] = strtoul(p, &end, base);
}
chars[nchars++] = strtoul(p, &end, base);