Rename WideString::FromLocal() to FromDefANSI().
Be consistent with WideString::ToDefANSI(), which is its inverse
operation.
Change-Id: I98392e33cc131fa2ab2352e879c0741ee906b581
Reviewed-on: https://pdfium-review.googlesource.com/c/45810
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp
index ed5f46b..2d2ff03 100644
--- a/core/fpdfdoc/cpdf_action.cpp
+++ b/core/fpdfdoc/cpdf_action.cpp
@@ -80,7 +80,7 @@
if (!pWinDict)
return WideString();
- return WideString::FromLocal(
+ return WideString::FromDefANSI(
pWinDict->GetStringFor(pdfium::stream::kF).AsStringView());
}
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp
index aa93b91..402f064 100644
--- a/core/fpdfdoc/cpdf_filespec.cpp
+++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -100,7 +100,7 @@
if (const CPDF_Dictionary* pDict = m_pObj->AsDictionary()) {
csFileName = pDict->GetUnicodeTextFor("UF");
if (csFileName.IsEmpty()) {
- csFileName = WideString::FromLocal(
+ csFileName = WideString::FromDefANSI(
pDict->GetStringFor(pdfium::stream::kF).AsStringView());
}
if (pDict->GetStringFor("FS") == "URL")
@@ -111,13 +111,13 @@
for (const auto* key : keys) {
if (pDict->KeyExist(key)) {
csFileName =
- WideString::FromLocal(pDict->GetStringFor(key).AsStringView());
+ WideString::FromDefANSI(pDict->GetStringFor(key).AsStringView());
break;
}
}
}
} else if (m_pObj->IsString()) {
- csFileName = WideString::FromLocal(m_pObj->GetString().AsStringView());
+ csFileName = WideString::FromDefANSI(m_pObj->GetString().AsStringView());
}
return DecodeFileName(csFileName);
}
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index 146de3a..55bb83b 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -864,7 +864,7 @@
}
// static
-WideString WideString::FromLocal(const ByteStringView& bstr) {
+WideString WideString::FromDefANSI(const ByteStringView& bstr) {
int src_len = bstr.GetLength();
int dest_len = FXSYS_MultiByteToWideChar(
FX_CODEPAGE_DefANSI, 0, bstr.unterminated_c_str(), src_len, nullptr, 0);
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index 799eb98..3c81093 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -60,7 +60,7 @@
~WideString();
- static WideString FromLocal(const ByteStringView& str) WARN_UNUSED_RESULT;
+ static WideString FromDefANSI(const ByteStringView& str) WARN_UNUSED_RESULT;
static WideString FromUTF8(const ByteStringView& str) WARN_UNUSED_RESULT;
static WideString FromUTF16LE(const unsigned short* str,
size_t len) WARN_UNUSED_RESULT;
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 0d20d71..601e287 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -1028,7 +1028,7 @@
}
TEST(WideString, FromLocal) {
- EXPECT_EQ(L"", WideString::FromLocal(ByteStringView()));
+ EXPECT_EQ(L"", WideString::FromDefANSI(ByteStringView()));
#if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
const wchar_t* kResult =
L"x"
@@ -1042,10 +1042,10 @@
L"\u00ff"
L"y";
#endif
- EXPECT_EQ(kResult, WideString::FromLocal("x"
- "\x80"
- "\xff"
- "y"));
+ EXPECT_EQ(kResult, WideString::FromDefANSI("x"
+ "\x80"
+ "\xff"
+ "y"));
}
TEST(WideStringView, FromVector) {
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 55c385c..4b77cdc 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -589,7 +589,7 @@
if (face.EqualNoCase(facebuf))
return hFont;
- WideString wsFace = WideString::FromLocal(facebuf);
+ WideString wsFace = WideString::FromDefANSI(facebuf);
for (size_t i = 0; i < FX_ArraySize(g_VariantNames); ++i) {
if (face != g_VariantNames[i].m_pFaceName)
continue;
diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp
index 23cc633..1a7cd45 100644
--- a/core/fxge/win32/fx_win32_dib.cpp
+++ b/core/fxge/win32/fx_win32_dib.cpp
@@ -152,7 +152,7 @@
}
RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile(const char* filename) {
- return LoadFromFile(WideString::FromLocal(filename).c_str());
+ return LoadFromFile(WideString::FromDefANSI(filename).c_str());
}
RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) {
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index 4cfb767..9e8f4bf 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -125,7 +125,7 @@
return WideString();
pBuff.resize(nActualLen);
- return WideString::FromLocal(ByteStringView(pBuff));
+ return WideString::FromDefANSI(ByteStringView(pBuff));
}
void CPDFSDK_FormFillEnvironment::JS_docmailForm(void* mailData,
@@ -194,7 +194,7 @@
return WideString();
pBuff.resize(nActualLen);
- return WideString::FromLocal(ByteStringView(pBuff));
+ return WideString::FromDefANSI(ByteStringView(pBuff));
}
void CPDFSDK_FormFillEnvironment::JS_docSubmitForm(void* formData,
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index cbb8764..c781ba1 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -401,7 +401,7 @@
return;
ByteString csTitle = pInfoDict->GetStringFor("Title");
- wsTitle = WideString::FromLocal(csTitle.AsStringView());
+ wsTitle = WideString::FromDefANSI(csTitle.AsStringView());
}
void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc,
@@ -644,7 +644,7 @@
if (!pFormFillEnv)
return false;
- pFormFillEnv->JS_appAlert(WideString::FromLocal(IDS_XFA_Validate_Input),
+ pFormFillEnv->JS_appAlert(WideString::FromDefANSI(IDS_XFA_Validate_Input),
L"", JSPLATFORM_ALERT_BUTTON_OK,
JSPLATFORM_ALERT_ICON_WARNING);
return false;
@@ -899,7 +899,7 @@
WideString csURL = submit->GetSubmitTarget();
if (csURL.IsEmpty()) {
- pFormFillEnv->JS_appAlert(WideString::FromLocal("Submit cancelled."), L"",
+ pFormFillEnv->JS_appAlert(WideString::FromDefANSI("Submit cancelled."), L"",
JSPLATFORM_ALERT_BUTTON_OK,
JSPLATFORM_ALERT_ICON_ASTERISK);
return false;
@@ -912,7 +912,7 @@
WideString csContent = submit->GetSubmitXDPContent();
csContent.Trim();
- WideString space = WideString::FromLocal(" ");
+ WideString space = WideString::FromDefANSI(" ");
csContent = space + csContent + space;
FPDF_DWORD flag = 0;
if (submit->IsSubmitEmbedPDF())
diff --git a/fxbarcode/BC_UtilCodingConvert.cpp b/fxbarcode/BC_UtilCodingConvert.cpp
index 96aeadd..f367c21 100644
--- a/fxbarcode/BC_UtilCodingConvert.cpp
+++ b/fxbarcode/BC_UtilCodingConvert.cpp
@@ -17,13 +17,13 @@
void CBC_UtilCodingConvert::LocaleToUtf8(const ByteString& src,
ByteString& dst) {
- WideString unicode = WideString::FromLocal(src.AsStringView());
+ WideString unicode = WideString::FromDefANSI(src.AsStringView());
dst = unicode.UTF8Encode();
}
void CBC_UtilCodingConvert::LocaleToUtf8(const ByteString& src,
std::vector<uint8_t>& dst) {
- WideString unicode = WideString::FromLocal(src.AsStringView());
+ WideString unicode = WideString::FromDefANSI(src.AsStringView());
ByteString utf8 = unicode.UTF8Encode();
dst = std::vector<uint8_t>(utf8.begin(), utf8.end());
}
diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp
index 7b0dee6..e23e4eb 100644
--- a/fxjs/cjs_annot.cpp
+++ b/fxjs/cjs_annot.cpp
@@ -103,7 +103,7 @@
return CJS_Result::Failure(JSMessage::kBadObjectError);
return CJS_Result::Success(pRuntime->NewString(
- WideString::FromLocal(
+ WideString::FromDefANSI(
CPDF_Annot::AnnotSubtypeToString(pBAAnnot->GetAnnotSubtype())
.AsStringView())
.AsStringView()));
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 2b68f47..4e00b70 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -1892,7 +1892,7 @@
break;
}
return CJS_Result::Success(pRuntime->NewString(
- WideString::FromLocal(csBCaption.AsStringView()).AsStringView()));
+ WideString::FromDefANSI(csBCaption.AsStringView()).AsStringView()));
}
CJS_Result CJS_Field::set_style(CJS_Runtime* pRuntime,
@@ -1978,7 +1978,7 @@
return CJS_Result::Failure(JSMessage::kBadObjectError);
return CJS_Result::Success(pRuntime->NewString(
- WideString::FromLocal(pFont->GetBaseFont().AsStringView())
+ WideString::FromDefANSI(pFont->GetBaseFont().AsStringView())
.AsStringView()));
}
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 6589f70..176872f 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -254,7 +254,7 @@
return CJS_Result::Success(pRuntime->NewBoolean(pData->bData));
case CFX_Value::DataType::STRING:
return CJS_Result::Success(pRuntime->NewString(
- WideString::FromLocal(pData->sData.AsStringView()).AsStringView()));
+ WideString::FromDefANSI(pData->sData.AsStringView()).AsStringView()));
case CFX_Value::DataType::OBJECT:
return CJS_Result::Success(
v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData));
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index ac5163d..529ca53 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -634,7 +634,7 @@
}
// Processing currency string
- Value = WideString::FromLocal(strValue.AsStringView());
+ Value = WideString::FromDefANSI(strValue.AsStringView());
if (bCurrencyPrepend)
Value = wstrCurrency + Value;
else
@@ -845,7 +845,7 @@
strValue.InsertAtFront('-');
strValue += '%';
- Value = WideString::FromLocal(strValue.AsStringView());
+ Value = WideString::FromDefANSI(strValue.AsStringView());
#endif
return CJS_Result::Success();
}
diff --git a/fxjs/js_resources.cpp b/fxjs/js_resources.cpp
index 05b5b37..8e891a0 100644
--- a/fxjs/js_resources.cpp
+++ b/fxjs/js_resources.cpp
@@ -67,10 +67,10 @@
WideString JSFormatErrorString(const char* class_name,
const char* property_name,
const WideString& details) {
- WideString result = WideString::FromLocal(class_name);
+ WideString result = WideString::FromDefANSI(class_name);
if (property_name) {
result += L".";
- result += WideString::FromLocal(property_name);
+ result += WideString::FromDefANSI(property_name);
}
result += L": ";
result += details;
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 7c88398..9a132b1 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -646,7 +646,7 @@
continue;
WideString wsFaceName =
- WideString::FromLocal(pFontMapper->GetFaceName(i).AsStringView());
+ WideString::FromDefANSI(pFontMapper->GetFaceName(i).AsStringView());
RegisterFaces(pFontStream, &wsFaceName);
}
@@ -775,7 +775,7 @@
pFont->m_wsFamilyNames.push_back(WideString::FromUTF8(pFace->family_name));
pFont->m_wsFaceName =
pFaceName ? *pFaceName
- : WideString::FromLocal(FXFT_Get_Postscript_Name(pFace));
+ : WideString::FromDefANSI(FXFT_Get_Postscript_Name(pFace));
pFont->m_nFaceIndex = pFace->face_index;
m_InstalledFonts.push_back(std::move(pFont));
}
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index 4d5fb9f..764542f 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -113,9 +113,9 @@
WideString CFGAS_GEFont::GetFamilyName() const {
if (!m_pFont->GetSubstFont() ||
m_pFont->GetSubstFont()->m_Family.GetLength() == 0) {
- return WideString::FromLocal(m_pFont->GetFamilyName().AsStringView());
+ return WideString::FromDefANSI(m_pFont->GetFamilyName().AsStringView());
}
- return WideString::FromLocal(
+ return WideString::FromDefANSI(
m_pFont->GetSubstFont()->m_Family.AsStringView());
}