aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2021-01-23 23:58:23 +0100
committerJay Berkenbilt <ejb@ql.org>2021-01-24 09:27:28 +0100
commit04edfe9fade7e77342f5e4fe694ee071554a119c (patch)
treee198ad6dd5d6e4759728c333363898d41690cf6e /include
parent63e5cb533de0567612ef5ab373d02f90880a8653 (diff)
downloadqpdf-04edfe9fade7e77342f5e4fe694ee071554a119c.tar.zst
QPDFObjectHandle::newUnicodeString to uses UTF-16 only when needed
Use the first of ASCII, PDFDocEncoding, or UTF-16 that is capable of encoding the string.
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDFObjectHandle.hh10
1 files changed, 6 insertions, 4 deletions
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index 84f71836..b28568ed 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -480,10 +480,12 @@ class QPDFObjectHandle
static QPDFObjectHandle newName(std::string const& name);
QPDF_DLL
static QPDFObjectHandle newString(std::string const& str);
- // Create a string encoded in UTF-16 from the given utf8-encoded
- // string. Such strings are appropriately encoded to appear in PDF
- // files outside of content streams, such as in document metadata
- // form field values, page labels, outlines, and similar locations.
+ // Create a string encoded from the given utf8-encoded string
+ // appropriately encoded to appear in PDF files outside of content
+ // streams, such as in document metadata form field values, page
+ // labels, outlines, and similar locations. We try ASCII first,
+ // then PDFDocEncoding, then UTF-16 as needed to successfully
+ // encode all the characters.
QPDF_DLL
static QPDFObjectHandle newUnicodeString(std::string const& utf8_str);
QPDF_DLL