Remove unused form of PDF_EncodeText().

Perform indexing via WideString::operator[] which will at least
assert bounds, if not enforce them.

Change-Id: I7b03cfd718c4acd642af910c2ca06f86d178e5fd
Reviewed-on: https://pdfium-review.googlesource.com/39873
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 9ccca12..928d650 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -467,21 +467,18 @@
                         bstr.GetLength());
 }
 
-ByteString PDF_EncodeText(const wchar_t* pString, int len) {
-  if (len == -1)
-    len = wcslen(pString);
-
-  int i;
+ByteString PDF_EncodeText(const WideString& str) {
+  size_t i = 0;
+  size_t len = str.GetLength();
   ByteString result;
   {
     pdfium::span<char> dest_buf = result.GetBuffer(len);
     for (i = 0; i < len; ++i) {
       int code;
       for (code = 0; code < 256; ++code) {
-        if (PDFDocEncoding[code] == pString[i])
+        if (PDFDocEncoding[code] == str[i])
           break;
       }
-
       if (code == 256)
         break;
 
@@ -504,19 +501,15 @@
         pdfium::as_writable_bytes(result.GetBuffer(encLen));
     dest_buf[dest_index++] = 0xfe;
     dest_buf[dest_index++] = 0xff;
-    for (int j = 0; j < len; ++j) {
-      dest_buf[dest_index++] = pString[j] >> 8;
-      dest_buf[dest_index++] = static_cast<uint8_t>(pString[j]);
+    for (size_t j = 0; j < len; ++j) {
+      dest_buf[dest_index++] = str[j] >> 8;
+      dest_buf[dest_index++] = static_cast<uint8_t>(str[j]);
     }
   }
   result.ReleaseBuffer(encLen);
   return result;
 }
 
-ByteString PDF_EncodeText(const WideString& str) {
-  return PDF_EncodeText(str.c_str(), str.GetLength());
-}
-
 ByteString PDF_EncodeString(const ByteString& src, bool bHex) {
   std::ostringstream result;
   int srclen = src.GetLength();
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h
index 328fd47..6522999 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.h
+++ b/core/fpdfapi/parser/fpdf_parser_decode.h
@@ -21,7 +21,6 @@
 ByteString PDF_EncodeString(const ByteString& src, bool bHex);
 WideString PDF_DecodeText(const uint8_t* pData, uint32_t size);
 WideString PDF_DecodeText(const ByteString& bstr);
-ByteString PDF_EncodeText(const wchar_t* pString, int len);
 ByteString PDF_EncodeText(const WideString& str);
 
 bool FlateEncode(const uint8_t* src_buf,