aboutsummaryrefslogtreecommitdiff
path: root/test/unicode_test.cc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2012-12-14 12:03:15 +0100
committerSebastian Geerken <devnull@localhost>2012-12-14 12:03:15 +0100
commit92816e0a00032975a59f2bac7d0ded61f6e3de29 (patch)
treef3f9eef25cd5a443f5f5650e2ef806c881030c84 /test/unicode_test.cc
parentf5380a56b1a6b83fea9b1c97140d4b1c8fe4ba49 (diff)
Extended test.
Diffstat (limited to 'test/unicode_test.cc')
-rw-r--r--test/unicode_test.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/test/unicode_test.cc b/test/unicode_test.cc
index 3cd43710..1cbb08b6 100644
--- a/test/unicode_test.cc
+++ b/test/unicode_test.cc
@@ -1,15 +1,36 @@
#include <string.h>
#include <stdio.h>
+#include <FL/fl_utf8.h>
#include "../lout/unicode.hh"
using namespace lout::unicode;
int main (int argc, char *argv[])
{
- const char *t = "abcäöüабв−‐";
+ // 0-terminated string
+ const char *t1 = "abcäöüабв−‐";
- for (const char *s = t; s; s = nextUtf8Char (s, strlen (s)))
- printf ("%3d -> U+%04x ('%s')\n", (int)(s - t), decodeUtf8(s), s);
+ // not 0-terminated; copy from 0-terminated
+ int t2len = strlen (t1);
+ char t2[t2len];
+ for (int i = 0; i < t2len; i++)
+ t2[i] = t1[i];
+
+ puts ("===== misc::unicode, 0-terminated =====");
+ for (const char *s = t1; s; s = nextUtf8Char (s))
+ printf ("%3d -> U+%04x ('%s')\n", (int)(s - t1), decodeUtf8(s), s);
+
+ puts ("===== Fltk, 0-terminated =====");
+ for (const char *s = t1; *s; s = fl_utf8fwd (s + 1, t1, t1 + strlen (t1)))
+ printf ("%3d -> U+%04x ('%s')\n", (int)(s - t1), decodeUtf8(s), s);
+
+ puts ("===== misc::unicode, not 0-terminated =====");
+ for (const char *s = t2; s; s = nextUtf8Char (s, t2len - (s - t2)))
+ printf ("%3d -> U+%04x\n", (int)(s - t2), decodeUtf8(s));
+
+ puts ("===== Fltk, not 0-terminated =====");
+ for (const char *s = t2; *s; s = fl_utf8fwd (s + 1, t2, t2 + t2len))
+ printf ("%3d -> U+%04x\n", (int)(s - t2), decodeUtf8(s));
return 0;
}