summaryrefslogtreecommitdiff
path: root/test/locale/show-ucs-data.c
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-07-09 15:05:36 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-07-09 15:05:36 +0000
commita691312d8794d5516402bb6bb0d3e90c40ba188b (patch)
treedcac242fcad7d24a4f452722de26c56cfaf8c98a /test/locale/show-ucs-data.c
parent56df95fe5d0778352abe09225d6587b88643d135 (diff)
Added several tests for locale support (8 bit and multibyte UTF-8)
Basically all tests have been taken from glibc. For testing multibyte encoding EUC_JP parts have been commented out and added new section for UTF-8 that is the only multibyte codeset currently supported on uCLibc. Some tests are still failing due to unsupported/missing features, other have been fixed. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'test/locale/show-ucs-data.c')
-rw-r--r--test/locale/show-ucs-data.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/locale/show-ucs-data.c b/test/locale/show-ucs-data.c
new file mode 100644
index 000000000..9992ece42
--- /dev/null
+++ b/test/locale/show-ucs-data.c
@@ -0,0 +1,62 @@
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+int
+main (int argc, char *argv[])
+{
+ int n;
+ char *line = NULL;
+ size_t len = 0;
+
+ for (n = 1; n < argc; ++n)
+ {
+ FILE *fp = fopen (argv[n], "r");
+ if (fp == NULL)
+ continue;
+
+ while (! feof (fp))
+ {
+ ssize_t cnt = getline (&line, &len, fp);
+ char *runp;
+ if (cnt <= 0)
+ break;
+
+ runp = line;
+ do
+ {
+ if (runp[0] == '<' && runp[1] == 'U' && isxdigit (runp[2])
+ && isxdigit (runp[3]) && isxdigit (runp[4])
+ && isxdigit (runp[5]) && runp[6] == '>')
+ {
+ unsigned int val = strtoul (runp + 2, NULL, 16);
+
+ //putchar ('<');
+ if (val < 128)
+ putchar (val);
+ else if (val < 0x800)
+ {
+ putchar (0xc0 | (val >> 6));
+ putchar (0x80 | (val & 0x3f));
+ }
+ else
+ {
+ putchar (0xe0 | (val >> 12));
+ putchar (0x80 | ((val >> 6) & 0x3f));
+ putchar (0x80 | (val & 0x3f));
+ }
+ //putchar ('>');
+ runp += 7;
+ }
+ else
+ putchar (*runp++);
+ }
+ while (runp < &line[cnt]);
+ }
+
+ fclose (fp);
+ }
+
+ return 0;
+}