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/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index 3c0ec30..0e553b2 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -86,7 +86,7 @@
   pAnnotDict->SetNewFor<CPDF_Name>("Subtype", "Popup");
   pAnnotDict->SetNewFor<CPDF_String>("T", pParentDict->GetStringFor("T"),
                                      false);
-  pAnnotDict->SetNewFor<CPDF_String>("Contents", sContents.UTF8Encode(), false);
+  pAnnotDict->SetNewFor<CPDF_String>("Contents", sContents.ToUTF8(), false);
 
   CFX_FloatRect rect = pParentDict->GetRectFor("Rect");
   rect.Normalize();
diff --git a/core/fpdfdoc/cpdf_filespec_unittest.cpp b/core/fpdfdoc/cpdf_filespec_unittest.cpp
index 73fc8a4..14c3ad6 100644
--- a/core/fpdfdoc/cpdf_filespec_unittest.cpp
+++ b/core/fpdfdoc/cpdf_filespec_unittest.cpp
@@ -205,7 +205,7 @@
       // Check that the file content stream is as expected.
       EXPECT_STREQ(
           streams[i],
-          file_spec.GetFileStream()->GetUnicodeText().UTF8Encode().c_str());
+          file_spec.GetFileStream()->GetUnicodeText().ToUTF8().c_str());
 
       if (i == 2) {
         dict_obj->SetNewFor<CPDF_String>("FS", "URL", false);
diff --git a/core/fpdfdoc/cpdf_formfield_unittest.cpp b/core/fpdfdoc/cpdf_formfield_unittest.cpp
index af5d15d..39e422d 100644
--- a/core/fpdfdoc/cpdf_formfield_unittest.cpp
+++ b/core/fpdfdoc/cpdf_formfield_unittest.cpp
@@ -17,32 +17,32 @@
   CPDF_Dictionary* root = obj_holder.NewIndirect<CPDF_Dictionary>();
   root->SetNewFor<CPDF_Name>("T", "foo");
   name = FPDF_GetFullName(root);
-  EXPECT_STREQ("foo", name.UTF8Encode().c_str());
+  EXPECT_STREQ("foo", name.ToUTF8().c_str());
 
   CPDF_Dictionary* dict1 = obj_holder.NewIndirect<CPDF_Dictionary>();
   root->SetNewFor<CPDF_Reference>("Parent", &obj_holder, dict1->GetObjNum());
   dict1->SetNewFor<CPDF_Name>("T", "bar");
   name = FPDF_GetFullName(root);
-  EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str());
+  EXPECT_STREQ("bar.foo", name.ToUTF8().c_str());
 
   CPDF_Dictionary* dict2 = dict1->SetNewFor<CPDF_Dictionary>("Parent");
   name = FPDF_GetFullName(root);
-  EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str());
+  EXPECT_STREQ("bar.foo", name.ToUTF8().c_str());
 
   CPDF_Dictionary* dict3 = obj_holder.NewIndirect<CPDF_Dictionary>();
   dict2->SetNewFor<CPDF_Reference>("Parent", &obj_holder, dict3->GetObjNum());
 
   dict3->SetNewFor<CPDF_Name>("T", "qux");
   name = FPDF_GetFullName(root);
-  EXPECT_STREQ("qux.bar.foo", name.UTF8Encode().c_str());
+  EXPECT_STREQ("qux.bar.foo", name.ToUTF8().c_str());
 
   dict3->SetNewFor<CPDF_Reference>("Parent", &obj_holder, root->GetObjNum());
   name = FPDF_GetFullName(root);
-  EXPECT_STREQ("qux.bar.foo", name.UTF8Encode().c_str());
+  EXPECT_STREQ("qux.bar.foo", name.ToUTF8().c_str());
   name = FPDF_GetFullName(dict1);
-  EXPECT_STREQ("foo.qux.bar", name.UTF8Encode().c_str());
+  EXPECT_STREQ("foo.qux.bar", name.ToUTF8().c_str());
   name = FPDF_GetFullName(dict2);
-  EXPECT_STREQ("bar.foo.qux", name.UTF8Encode().c_str());
+  EXPECT_STREQ("bar.foo.qux", name.ToUTF8().c_str());
   name = FPDF_GetFullName(dict3);
-  EXPECT_STREQ("bar.foo.qux", name.UTF8Encode().c_str());
+  EXPECT_STREQ("bar.foo.qux", name.ToUTF8().c_str());
 }
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());
 }