aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qutil.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-16 03:06:38 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-17 17:43:56 +0100
commite87d149918ed6ed211f733f932df3b62ab445c12 (patch)
tree40c8e30e2296a7569433387a5f047b27e505875d /libtests/qutil.cc
parent997f4ab6cbec6be5e045bc4210d315a4e0ab76d4 (diff)
downloadqpdf-e87d149918ed6ed211f733f932df3b62ab445c12.tar.zst
Add QUtil::possible_repaired_encodings
Diffstat (limited to 'libtests/qutil.cc')
-rw-r--r--libtests/qutil.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index 35877b9c..27881c6e 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -276,6 +276,16 @@ void check_analyze(std::string const& str, bool has8bit, bool utf8, bool utf16)
}
}
+void print_alternatives(std::string const& str)
+{
+ std::vector<std::string> result = QUtil::possible_repaired_encodings(str);
+ size_t n = result.size();
+ for (size_t i = 0; i < n; ++i)
+ {
+ std::cout << i << ": " << QUtil::hex_encode(result.at(i)) << std::endl;
+ }
+}
+
void transcoding_test()
{
transcoding_test(&QUtil::pdf_doc_to_utf8,
@@ -308,6 +318,18 @@ void transcoding_test()
assert(QUtil::utf8_to_pdf_doc(input1, output));
assert(! QUtil::utf8_to_pdf_doc(input2, output));
assert(QUtil::utf8_to_pdf_doc(input3, output));
+ std::cout << "alternatives" << std::endl;
+ // char name mac win pdf-doc
+ // U+0192 florin 304 203 206
+ // U+00A9 copyright 251 251 251
+ // U+00E9 eacute 216 351 351
+ // U+017E zcaron - 236 236
+ std::string pdfdoc = "\206\251\351\236";
+ std::string utf8 = QUtil::pdf_doc_to_utf8(pdfdoc);
+ print_alternatives(pdfdoc);
+ print_alternatives(utf8);
+ print_alternatives("quack");
+ std::cout << "done alternatives" << std::endl;
}
void print_whoami(char const* str)