summaryrefslogtreecommitdiff
path: root/src/test/test-utf8.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-12-22 12:57:05 +0100
committerTom Gundersen <teg@jklm.no>2014-12-22 20:26:53 +0100
commit04166cb7dd90918385835f246c43d8ec22af0d68 (patch)
treef5877cd3e9c5edd3b37c6cdc9d229c79a40ade31 /src/test/test-utf8.c
parent2bb4c7e384c31de4727f1330da3f4de2f0bb7784 (diff)
shared: utf8 - support decoding the full utf16
We originally only supported the BMP (i.e., we treated UTF-16 as UCS-2).
Diffstat (limited to 'src/test/test-utf8.c')
-rw-r--r--src/test/test-utf8.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c
index 3399f2ba9c..befa385754 100644
--- a/src/test/test-utf8.c
+++ b/src/test/test-utf8.c
@@ -93,6 +93,18 @@ static void test_utf8_escaping_printable(void) {
assert_se(utf8_is_valid(p6));
}
+static void test_utf16_to_utf8(void) {
+ char *a = NULL;
+ const uint16_t utf16[] = { 'a', 0xd800, 'b', 0xdc00, 'c', 0xd801, 0xdc37 };
+ const char utf8[] = { 'a', 'b', 'c', 0xf0, 0x90, 0x90, 0xb7, 0 };
+
+ a = utf16_to_utf8(utf16, 14);
+ assert_se(a);
+ assert_se(streq(a, utf8));
+
+ free(a);
+}
+
int main(int argc, char *argv[]) {
test_utf8_is_valid();
test_utf8_is_printable();
@@ -100,6 +112,7 @@ int main(int argc, char *argv[]) {
test_utf8_encoded_valid_unichar();
test_utf8_escaping();
test_utf8_escaping_printable();
+ test_utf16_to_utf8();
return 0;
}