Rename WideString::{UTF8,UTF16LE}_Encode() to To{UTF8,UTF16LE}().

Make consistent with ToDefANSI().

Change-Id: I576f5a8a2bb3f633c7dca67efd7712fa610acf4d
Reviewed-on: https://pdfium-review.googlesource.com/c/45791
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index 55bb83b..234270e 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -654,11 +654,11 @@
   return bstr;
 }
 
-ByteString WideString::UTF8Encode() const {
+ByteString WideString::ToUTF8() const {
   return FX_UTF8Encode(AsStringView());
 }
 
-ByteString WideString::UTF16LE_Encode() const {
+ByteString WideString::ToUTF16LE() const {
   if (!m_pData)
     return ByteString("\0\0", 2);
 
@@ -1033,7 +1033,7 @@
 }
 
 std::ostream& operator<<(std::ostream& os, const WideString& str) {
-  os << str.UTF8Encode();
+  os << str.ToUTF8();
   return os;
 }
 
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index 3c81093..70339ff 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -192,12 +192,12 @@
   size_t Remove(wchar_t ch);
 
   ByteString ToDefANSI() const;
-  ByteString UTF8Encode() const;
+  ByteString ToUTF8() const;
 
   // This method will add \0\0 to the end of the string to represent the
   // wide string terminator. These values are in the string, not just the data,
   // so GetLength() will include them.
-  ByteString UTF16LE_Encode() const;
+  ByteString ToUTF16LE() const;
 
  protected:
   using StringData = StringDataTemplate<wchar_t>;
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 601e287..2d8a676 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -981,7 +981,7 @@
   EXPECT_TRUE(iter == multi_str.rbegin());
 }
 
-TEST(WideString, UTF16LE_Encode) {
+TEST(WideString, ToUTF16LE) {
   struct UTF16LEEncodeCase {
     WideString ws;
     ByteString bs;
@@ -996,7 +996,7 @@
 
   for (size_t i = 0; i < FX_ArraySize(utf16le_encode_cases); ++i) {
     EXPECT_EQ(utf16le_encode_cases[i].bs,
-              utf16le_encode_cases[i].ws.UTF16LE_Encode())
+              utf16le_encode_cases[i].ws.ToUTF16LE())
         << " for case number " << i;
   }
 }
diff --git a/core/fxcrt/xml/cfx_xmlchardata.cpp b/core/fxcrt/xml/cfx_xmlchardata.cpp
index d5fae18..395435c 100644
--- a/core/fxcrt/xml/cfx_xmlchardata.cpp
+++ b/core/fxcrt/xml/cfx_xmlchardata.cpp
@@ -24,6 +24,6 @@
 void CFX_XMLCharData::Save(
     const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) {
   pXMLStream->WriteString("<![CDATA[");
-  pXMLStream->WriteString(GetText().UTF8Encode().AsStringView());
+  pXMLStream->WriteString(GetText().ToUTF8().AsStringView());
   pXMLStream->WriteString("]]>");
 }
diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp
index 87e50f4..02b3fcc 100644
--- a/core/fxcrt/xml/cfx_xmlelement.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement.cpp
@@ -84,7 +84,7 @@
 
 void CFX_XMLElement::Save(
     const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) {
-  ByteString bsNameEncoded = name_.UTF8Encode();
+  ByteString bsNameEncoded = name_.ToUTF8();
 
   pXMLStream->WriteString("<");
   pXMLStream->WriteString(bsNameEncoded.AsStringView());
@@ -93,7 +93,7 @@
     // Note, the space between attributes is added by AttributeToString which
     // writes a blank as the first character.
     pXMLStream->WriteString(
-        AttributeToString(it.first, it.second).UTF8Encode().AsStringView());
+        AttributeToString(it.first, it.second).ToUTF8().AsStringView());
   }
 
   if (!GetFirstChild()) {
diff --git a/core/fxcrt/xml/cfx_xmlinstruction.cpp b/core/fxcrt/xml/cfx_xmlinstruction.cpp
index fb534e3..73fe548 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction.cpp
+++ b/core/fxcrt/xml/cfx_xmlinstruction.cpp
@@ -47,11 +47,11 @@
   }
 
   pXMLStream->WriteString("<?");
-  pXMLStream->WriteString(name_.UTF8Encode().AsStringView());
+  pXMLStream->WriteString(name_.ToUTF8().AsStringView());
   pXMLStream->WriteString(" ");
 
   for (const WideString& target : target_data_) {
-    pXMLStream->WriteString(target.UTF8Encode().AsStringView());
+    pXMLStream->WriteString(target.ToUTF8().AsStringView());
     pXMLStream->WriteString(" ");
   }
 
diff --git a/core/fxcrt/xml/cfx_xmltext.cpp b/core/fxcrt/xml/cfx_xmltext.cpp
index b6c1be7..b73316b 100644
--- a/core/fxcrt/xml/cfx_xmltext.cpp
+++ b/core/fxcrt/xml/cfx_xmltext.cpp
@@ -21,6 +21,5 @@
 }
 
 void CFX_XMLText::Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) {
-  pXMLStream->WriteString(
-      EncodeEntities(GetText()).UTF8Encode().AsStringView());
+  pXMLStream->WriteString(EncodeEntities(GetText()).ToUTF8().AsStringView());
 }