diff options
author | m-holger <m-holger@kubitscheck.org> | 2022-02-04 18:15:34 +0100 |
---|---|---|
committer | Jay Berkenbilt <jberkenbilt@users.noreply.github.com> | 2022-02-04 19:10:51 +0100 |
commit | 95e7d36b7a9d2c241cfb9e67745c653343bb73c3 (patch) | |
tree | 090a2f53b61a1d4d8b3ee0b9e60a31f0f5d923bb /qpdf | |
parent | 3c138be0efa2daf1e5e162edf1100cf5e8b5521c (diff) | |
download | qpdf-95e7d36b7a9d2c241cfb9e67745c653343bb73c3.tar.zst |
C-API add two binary UTF8 funtions
add qpdf_oh_new_binary_unicode_string and qpdf_oh_get_binary_utf8_value
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/qpdf-ctest.c | 23 | ||||
-rw-r--r-- | qpdf/qpdf.testcov | 2 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/c-object-handle-creation-out.pdf | 15 |
3 files changed, 32 insertions, 8 deletions
diff --git a/qpdf/qpdf-ctest.c b/qpdf/qpdf-ctest.c index e9a7f1a8..414c0eaa 100644 --- a/qpdf/qpdf-ctest.c +++ b/qpdf/qpdf-ctest.c @@ -740,10 +740,13 @@ static void test25(char const* infile, qpdf_oh_append_item( qpdf, new_array, qpdf_oh_new_unicode_string(qpdf, "qww\xc3\xb7\xcf\x80")); + qpdf_oh_append_item( + qpdf, new_array, + qpdf_oh_new_binary_unicode_string(qpdf, "qw\x00w\xc3\xb7\xcf\x80", 8)); qpdf_oh_append_item(qpdf, new_array, qpdf_oh_new_null(qpdf)); /* 2 */ qpdf_oh_append_item(qpdf, new_array, qpdf_oh_new_null(qpdf)); /* 3 */ qpdf_oh_set_array_item( - qpdf, new_array, 2, + qpdf, new_array, 3, qpdf_oh_new_name(qpdf, "/Quack")); qpdf_oh_append_item( qpdf, new_array, @@ -803,6 +806,24 @@ static void test27(char const* infile, "potato\000salad", 13) == 0); assert(qpdf_get_last_string_length(qpdf) == 12); assert(length == 12); + /* repeat for UTF8 string */ + qpdf_oh p_utf8_string_with_null = qpdf_oh_parse(qpdf, + "<feff007100770000007700f703c0>"); + assert(qpdf_oh_is_string(qpdf, p_utf8_string_with_null)); + assert(strcmp(qpdf_oh_get_utf8_value(qpdf, p_utf8_string_with_null), + "qw\x00w\xc3\xb7\xcf\x80") == 0); + assert(qpdf_get_last_string_length(qpdf) == 8); + /* memcmp adds a character to verify the trailing null */ + assert(memcmp(qpdf_oh_get_utf8_value(qpdf, p_utf8_string_with_null), + "qw\x00w\xc3\xb7\xcf\x80", 8) == 0); + p_utf8_string_with_null = qpdf_oh_new_binary_unicode_string( + qpdf, "qw\x00w\xc3\xb7\xcf\x80", 8); + /* memcmp adds a character to verify the trailing null */ + assert(memcmp(qpdf_oh_get_binary_utf8_value( + qpdf, p_utf8_string_with_null, &length), + "qw\x00w\xc3\xb7\xcf\x80", 9) == 0); + assert(qpdf_get_last_string_length(qpdf) == 8); + assert(length == 8); } static void test28(char const* infile, diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov index 28af71cb..1e0f336e 100644 --- a/qpdf/qpdf.testcov +++ b/qpdf/qpdf.testcov @@ -620,7 +620,9 @@ qpdf-c called qpdf_oh_get_page_content_data 0 qpdf-c called qpdf_oh_replace_stream_data 0 qpdf-c silence oh errors 0 qpdf-c called qpdf_oh_get_binary_string_value 0 +qpdf-c called qpdf_oh_get_binary_utf8_value 0 qpdf-c called qpdf_oh_new_binary_string 0 +qpdf-c called qpdf_oh_new_binary_unicode_string 0 QPDFJob duplicated pages password 0 QPDFJob misplaced pages password 0 QPDFJob check encrypted encrypted 0 diff --git a/qpdf/qtest/qpdf/c-object-handle-creation-out.pdf b/qpdf/qtest/qpdf/c-object-handle-creation-out.pdf index 729feb0d..a3ec67b8 100644 --- a/qpdf/qtest/qpdf/c-object-handle-creation-out.pdf +++ b/qpdf/qtest/qpdf/c-object-handle-creation-out.pdf @@ -9,6 +9,7 @@ /B [ (potato) <feff00710077007700f703c0> + <feff007100770000007700f703c0> /Quack null 4.12 @@ -95,17 +96,17 @@ xref 0 8 0000000000 65535 f 0000000025 00000 n -0000000277 00000 n -0000000359 00000 n -0000000574 00000 n -0000000673 00000 n -0000000692 00000 n -0000000810 00000 n +0000000314 00000 n +0000000396 00000 n +0000000611 00000 n +0000000710 00000 n +0000000729 00000 n +0000000847 00000 n trailer << /Root 1 0 R /Size 8 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>] >> startxref -845 +882 %%EOF |