Commit a367a367d4626d2a70f566475800c76f10f1f315
1 parent
09ac645b
Refactor `QPDFObjectHandle::newUnicodeString`: remove `QPDF_String::create_utf16…
…` and replace with `String::utf16`.
Showing
4 changed files
with
13 additions
and
12 deletions
libqpdf/QPDFObjectHandle.cc
| ... | ... | @@ -1010,7 +1010,7 @@ QPDFObjectHandle::newString(std::string const& str) |
| 1010 | 1010 | QPDFObjectHandle |
| 1011 | 1011 | QPDFObjectHandle::newUnicodeString(std::string const& utf8_str) |
| 1012 | 1012 | { |
| 1013 | - return {QPDF_String::create_utf16(utf8_str)}; | |
| 1013 | + return {String::utf16(utf8_str).obj_sp()}; | |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | String::String(std::string const& str) : |
| ... | ... | @@ -1023,6 +1023,16 @@ String::String(std::string&& str) : |
| 1023 | 1023 | { |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | +String | |
| 1027 | +String::utf16(std::string const& utf8_str) | |
| 1028 | +{ | |
| 1029 | + std::string result; | |
| 1030 | + if (QUtil::utf8_to_pdf_doc(utf8_str, result, '?')) { | |
| 1031 | + return String(result); | |
| 1032 | + } | |
| 1033 | + return String(QUtil::utf8_to_utf16(utf8_str)); | |
| 1034 | +} | |
| 1035 | + | |
| 1026 | 1036 | std::string const& |
| 1027 | 1037 | String::value() const |
| 1028 | 1038 | { | ... | ... |
libqpdf/QPDF_String.cc
| ... | ... | @@ -13,16 +13,6 @@ is_iso_latin1_printable(char ch) |
| 13 | 13 | return (ch >= 32 && ch <= 126) || static_cast<unsigned char>(ch) >= 160; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -std::shared_ptr<QPDFObject> | |
| 17 | -QPDF_String::create_utf16(std::string const& utf8_val) | |
| 18 | -{ | |
| 19 | - std::string result; | |
| 20 | - if (!QUtil::utf8_to_pdf_doc(utf8_val, result, '?')) { | |
| 21 | - result = QUtil::utf8_to_utf16(utf8_val); | |
| 22 | - } | |
| 23 | - return QPDFObject::create<QPDF_String>(result); | |
| 24 | -} | |
| 25 | - | |
| 26 | 16 | void |
| 27 | 17 | QPDF_String::writeJSON(int json_version, JSON::Writer& p) |
| 28 | 18 | { | ... | ... |
libqpdf/qpdf/QPDFObjectHandle_private.hh
libqpdf/qpdf/QPDFObject_private.hh
| ... | ... | @@ -266,7 +266,6 @@ class QPDF_String final |
| 266 | 266 | friend class qpdf::impl::Writer; |
| 267 | 267 | |
| 268 | 268 | public: |
| 269 | - static std::shared_ptr<QPDFObject> create_utf16(std::string const& utf8_val); | |
| 270 | 269 | std::string unparse(bool force_binary = false); |
| 271 | 270 | void writeJSON(int json_version, JSON::Writer& p); |
| 272 | 271 | ... | ... |