diff options
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_decode.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index 3d7b9ffd59..a2ba203488 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -9,6 +9,7 @@ #include <limits.h> #include <algorithm> +#include <sstream> #include <utility> #include <vector> @@ -512,20 +513,20 @@ CFX_ByteString PDF_EncodeText(const CFX_WideString& str) { } CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) { - CFX_ByteTextBuf result; + std::ostringstream result; int srclen = src.GetLength(); if (bHex) { - result.AppendChar('<'); + result << '<'; for (int i = 0; i < srclen; i++) { char buf[2]; FXSYS_IntToTwoHexChars(src[i], buf); - result.AppendChar(buf[0]); - result.AppendChar(buf[1]); + result << buf[0]; + result << buf[1]; } - result.AppendChar('>'); - return result.MakeString(); + result << '>'; + return CFX_ByteString(result); } - result.AppendChar('('); + result << '('; for (int i = 0; i < srclen; i++) { uint8_t ch = src[i]; if (ch == 0x0a) { @@ -537,11 +538,11 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) { continue; } if (ch == ')' || ch == '\\' || ch == '(') - result.AppendChar('\\'); - result.AppendChar(ch); + result << '\\'; + result << static_cast<char>(ch); } - result.AppendChar(')'); - return result.MakeString(); + result << ')'; + return CFX_ByteString(result); } bool FlateEncode(const uint8_t* src_buf, |