aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qutil.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-06-21 19:05:48 +0200
committerJay Berkenbilt <ejb@ql.org>2018-06-21 21:57:13 +0200
commite44c395c51518bafbf8f8466ea5a0f4b1f2b2efe (patch)
tree95da31b1da0055ee2b605272f7079c7ea230584c /libtests/qutil.cc
parent44674a3e58882ea95d6ee54fa3e16c553c0afb3e (diff)
downloadqpdf-e44c395c51518bafbf8f8466ea5a0f4b1f2b2efe.tar.zst
QUtil::toUTF16
Diffstat (limited to 'libtests/qutil.cc')
-rw-r--r--libtests/qutil.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index ddb5815d..a7479fb5 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -193,6 +193,30 @@ void to_utf8_test()
}
}
+static void print_utf16(unsigned long val)
+{
+ std::string result = QUtil::toUTF16(val);
+ std::cout << "0x" << QUtil::int_to_string_base(val, 16) << " ->";
+ for (std::string::iterator iter = result.begin();
+ iter != result.end(); ++iter)
+ {
+ std::cout << " " << QUtil::int_to_string_base(
+ static_cast<int>(static_cast<unsigned char>(*iter)), 16, 2);
+ }
+ std::cout << std::endl;
+}
+
+void to_utf16_test()
+{
+ print_utf16(0x41UL);
+ print_utf16(0xF7UL);
+ print_utf16(0x3c0UL);
+ print_utf16(0x16059UL);
+ print_utf16(0xdeadUL);
+ print_utf16(0x7fffffffUL);
+ print_utf16(0x80000000UL);
+}
+
void print_whoami(char const* str)
{
PointerHolder<char> dup(true, QUtil::copy_string(str));
@@ -299,6 +323,8 @@ int main(int argc, char* argv[])
getenv_test();
std::cout << "---- utf8" << std::endl;
to_utf8_test();
+ std::cout << "---- utf16" << std::endl;
+ to_utf16_test();
std::cout << "---- whoami" << std::endl;
get_whoami_test();
std::cout << "---- file" << std::endl;