Use FXSYS_IntToTwoHexChars() in more places.

Change-Id: I84cd8e91a296119ecf80b7a092b886f291bebb45
Reviewed-on: https://pdfium-review.googlesource.com/4953
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index c521c20..64831e9 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -517,8 +517,10 @@
   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 1edf577..af109e3 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp
@@ -139,8 +139,8 @@
     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;
     }
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 2b290ed..10b568e 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -251,8 +251,6 @@
 }
 
 #ifdef PDF_ENABLE_XFA
-static const char gs_FX_pHexChars[] = "0123456789ABCDEF";
-
 void FX_GUID_CreateV4(FX_GUID* pGUID) {
   FX_Random_GenerateMT((uint32_t*)pGUID, 4);
   uint8_t& b = ((uint8_t*)pGUID)[6];
@@ -264,8 +262,8 @@
   char* pBuf = bsStr.GetBuffer(40);
   for (int32_t i = 0; i < 16; i++) {
     uint8_t b = reinterpret_cast<const uint8_t*>(pGUID)[i];
-    *pBuf++ = gs_FX_pHexChars[b >> 4];
-    *pBuf++ = gs_FX_pHexChars[b & 0x0F];
+    FXSYS_IntToTwoHexChars(b, pBuf);
+    pBuf += 2;
     if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9))
       *pBuf++ = L'-';
   }