From 370710657a7e7c771668107d1b6407fc350a2891 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 11 Jan 2022 15:06:17 -0500 Subject: Add missing characters from PDF doc encoding (fixes #606) --- libtests/qutil.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'libtests/qutil.cc') diff --git a/libtests/qutil.cc b/libtests/qutil.cc index 46eb840c..cd2b7796 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -308,12 +308,12 @@ void utf8_to_ascii_test() void transcoding_test(std::string (*to_utf8)(std::string const&), std::string (*from_utf8)(std::string const&, char), - int last, std::string unknown) + int first, int last, std::string unknown) { std::string in(" "); std::string out; std::string back; - for (int i = 128; i <= last; ++i) + for (int i = first; i <= last; ++i) { in.at(0) = static_cast(static_cast(i)); out = (*to_utf8)(in); @@ -355,13 +355,16 @@ void print_alternatives(std::string const& str) void transcoding_test() { transcoding_test(&QUtil::pdf_doc_to_utf8, - &QUtil::utf8_to_pdf_doc, 160, "\x9f"); + &QUtil::utf8_to_pdf_doc, 127, 160, "\x9f"); std::cout << "bidirectional pdf doc done" << std::endl; + transcoding_test(&QUtil::pdf_doc_to_utf8, + &QUtil::utf8_to_pdf_doc, 24, 31, "?"); + std::cout << "bidirectional pdf doc low done" << std::endl; transcoding_test(&QUtil::win_ansi_to_utf8, - &QUtil::utf8_to_win_ansi, 160, "?"); + &QUtil::utf8_to_win_ansi, 128, 160, "?"); std::cout << "bidirectional win ansi done" << std::endl; transcoding_test(&QUtil::mac_roman_to_utf8, - &QUtil::utf8_to_mac_roman, 255, "?"); + &QUtil::utf8_to_mac_roman, 128, 255, "?"); std::cout << "bidirectional mac roman done" << std::endl; check_analyze("pi = \317\200", true, true, false); check_analyze("pi != \317", true, false, false); @@ -396,6 +399,10 @@ void transcoding_test() print_alternatives(utf8); print_alternatives("quack"); std::cout << "done alternatives" << std::endl; + std::string low = QUtil::pdf_doc_to_utf8( + "w\030w\031w\032w\033w\034w\035w\036w\037w\177w"); + std::cout << low << std::endl; + std::cout << "done low characters" << std::endl; } void print_whoami(char const* str) -- cgit v1.2.3-54-g00ecf