mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
Format code
This commit is contained in:
parent
54d8e920f1
commit
2d402e451c
@ -1,9 +1,9 @@
|
||||
#include <qpdf/QPDFObjectHandle.hh>
|
||||
|
||||
#include <qpdf/BufferInputSource.hh>
|
||||
#include <qpdf/JSON_writer.hh>
|
||||
#include <qpdf/Pl_Buffer.hh>
|
||||
#include <qpdf/Pl_QPDFTokenizer.hh>
|
||||
#include <qpdf/JSON_writer.hh>
|
||||
#include <qpdf/QPDF.hh>
|
||||
#include <qpdf/QPDFExc.hh>
|
||||
#include <qpdf/QPDFLogger.hh>
|
||||
|
@ -51,22 +51,21 @@ QPDF_String::writeJSON(int json_version, JSON::Writer& p)
|
||||
{
|
||||
auto candidate = getUTF8Val();
|
||||
if (json_version == 1) {
|
||||
|
||||
p << "\"" << JSON::Writer::encode_string(candidate) << "\"";
|
||||
} else {
|
||||
// See if we can unambiguously represent as Unicode.
|
||||
if (QUtil::is_utf16(this->val) || QUtil::is_explicit_utf8(this->val)) {
|
||||
p << "\"u:" << JSON::Writer::encode_string(candidate) <<"\"";
|
||||
p << "\"u:" << JSON::Writer::encode_string(candidate) << "\"";
|
||||
return;
|
||||
} else if (!useHexString()) {
|
||||
std::string test;
|
||||
if (QUtil::utf8_to_pdf_doc(candidate, test, '?') && (test == this->val)) {
|
||||
// This is a PDF-doc string that can be losslessly encoded as Unicode.
|
||||
p << "\"u:" << JSON::Writer::encode_string(candidate) <<"\"";
|
||||
p << "\"u:" << JSON::Writer::encode_string(candidate) << "\"";
|
||||
return;
|
||||
}
|
||||
}
|
||||
p << "\"b:" << QUtil::hex_encode(val) <<"\"";
|
||||
p << "\"b:" << QUtil::hex_encode(val) << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user