summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.cpp6
-rw-r--r--core/fpdfapi/parser/fpdf_parser_utility.cpp4
2 files changed, 6 insertions, 4 deletions
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index c521c20665..64831e91e5 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -517,8 +517,10 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) {
if (bHex) {
result.AppendChar('<');
for (int i = 0; i < srclen; i++) {
- result.AppendChar("0123456789ABCDEF"[src[i] / 16]);
- result.AppendChar("0123456789ABCDEF"[src[i] % 16]);
+ char buf[2];
+ FXSYS_IntToTwoHexChars(src[i], buf);
+ result.AppendChar(buf[0]);
+ result.AppendChar(buf[1]);
}
result.AppendChar('>');
return result.MakeString();
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp
index 1edf577c5b..af109e35aa 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp
@@ -139,8 +139,8 @@ CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) {
if (ch >= 0x80 || PDFCharIsWhitespace(ch) || ch == '#' ||
PDFCharIsDelimiter(ch)) {
dest_buf[dest_len++] = '#';
- dest_buf[dest_len++] = "0123456789ABCDEF"[ch / 16];
- dest_buf[dest_len++] = "0123456789ABCDEF"[ch % 16];
+ FXSYS_IntToTwoHexChars(ch, dest_buf + dest_len);
+ dest_len += 2;
} else {
dest_buf[dest_len++] = ch;
}