From a35d4ce9ccb3eb5903df3d221fdfd9a0d1fb5c37 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 21 Jun 2019 17:36:59 -0400 Subject: Fix bounds error in utf16_to_utf8 conversion --- libtests/qtest/qutil/qutil.out | 2 ++ libtests/qutil.cc | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'libtests') diff --git a/libtests/qtest/qutil/qutil.out b/libtests/qtest/qutil/qutil.out index 2f270226..eb8eaf45 100644 --- a/libtests/qtest/qutil/qutil.out +++ b/libtests/qtest/qutil/qutil.out @@ -53,6 +53,8 @@ HAGOOGAMAGOOGLE: 0 0xdead -> ff fd 0x7fffffff -> ff fd 0x80000000 -> ff fd +π +π ---- utf8_to_ascii ¿Does π have fingers? ?Does ? have fingers? diff --git a/libtests/qutil.cc b/libtests/qutil.cc index 900f0e6f..a5c44fc5 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -238,6 +238,10 @@ void to_utf16_test() print_utf16(0xdeadUL); print_utf16(0x7fffffffUL); print_utf16(0x80000000UL); + + std::string s(QUtil::utf8_to_utf16("\xcf\x80")); + std::cout << QUtil::utf16_to_utf8(s) << std::endl; + std::cout << QUtil::utf16_to_utf8(s + ".") << std::endl; } void utf8_to_ascii_test() -- cgit v1.2.3-70-g09d2