From 02281632ccbba3ef00a6968bfd697f4be836d0dd Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 3 Jan 2019 20:03:30 -0500 Subject: Add QUtil::utf8_to_ascii --- libtests/qtest/qutil/qutil.out | 4 ++++ libtests/qutil.cc | 13 +++++++++++++ 2 files changed, 17 insertions(+) (limited to 'libtests') diff --git a/libtests/qtest/qutil/qutil.out b/libtests/qtest/qutil/qutil.out index 8223bf5b..f47301e4 100644 --- a/libtests/qtest/qutil/qutil.out +++ b/libtests/qtest/qutil/qutil.out @@ -47,6 +47,10 @@ HAGOOGAMAGOOGLE: 0 0xdead -> ff fd 0x7fffffff -> ff fd 0x80000000 -> ff fd +---- utf8_to_ascii +Does π have fingers? +Does ? have fingers? +Does * have fingers? ---- whoami quack1 quack2 diff --git a/libtests/qutil.cc b/libtests/qutil.cc index 025f4e43..de51da58 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -220,6 +220,17 @@ void to_utf16_test() print_utf16(0x80000000UL); } +void utf8_to_ascii_test() +{ + char const* input = "Does \317\200 have fingers?"; + std::cout << input + << std::endl + << QUtil::utf8_to_ascii(input) + << std::endl + << QUtil::utf8_to_ascii(input, '*') + << std::endl; +} + void print_whoami(char const* str) { PointerHolder dup(true, QUtil::copy_string(str)); @@ -328,6 +339,8 @@ int main(int argc, char* argv[]) to_utf8_test(); std::cout << "---- utf16" << std::endl; to_utf16_test(); + std::cout << "---- utf8_to_ascii" << std::endl; + utf8_to_ascii_test(); std::cout << "---- whoami" << std::endl; get_whoami_test(); std::cout << "---- file" << std::endl; -- cgit v1.2.3-70-g09d2