Remove more wide string literals.
There are all, in fact, 7-bit ASCII.
Change-Id: Ifb063cc983b73ea3acbc5a21c07ff344a9222135
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117630
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index 2548c3e..efed7e4 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -691,7 +691,7 @@
WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
DCHECK(GetType() == kCheckBox || GetType() == kRadioButton);
- WideString csExport = L"Off";
+ auto csExport = WideString::FromASCII("Off");
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
diff --git a/core/fxcrt/css/cfx_cssdata.cpp b/core/fxcrt/css/cfx_cssdata.cpp
index 99c3e60..3a85cb0 100644
--- a/core/fxcrt/css/cfx_cssdata.cpp
+++ b/core/fxcrt/css/cfx_cssdata.cpp
@@ -33,24 +33,24 @@
#undef CSS_PROP_VALUE____
const CFX_CSSData::LengthUnit kLengthUnitTable[] = {
- {L"cm", CFX_CSSNumber::Unit::kCentiMeters},
- {L"em", CFX_CSSNumber::Unit::kEMS},
- {L"ex", CFX_CSSNumber::Unit::kEXS},
- {L"in", CFX_CSSNumber::Unit::kInches},
- {L"mm", CFX_CSSNumber::Unit::kMilliMeters},
- {L"pc", CFX_CSSNumber::Unit::kPicas},
- {L"pt", CFX_CSSNumber::Unit::kPoints},
- {L"px", CFX_CSSNumber::Unit::kPixels},
+ {"cm", CFX_CSSNumber::Unit::kCentiMeters},
+ {"em", CFX_CSSNumber::Unit::kEMS},
+ {"ex", CFX_CSSNumber::Unit::kEXS},
+ {"in", CFX_CSSNumber::Unit::kInches},
+ {"mm", CFX_CSSNumber::Unit::kMilliMeters},
+ {"pc", CFX_CSSNumber::Unit::kPicas},
+ {"pt", CFX_CSSNumber::Unit::kPoints},
+ {"px", CFX_CSSNumber::Unit::kPixels},
};
// 16 colours from CSS 2.0 + alternate spelling of grey/gray.
const CFX_CSSData::Color kColorTable[] = {
- {L"aqua", 0xff00ffff}, {L"black", 0xff000000}, {L"blue", 0xff0000ff},
- {L"fuchsia", 0xffff00ff}, {L"gray", 0xff808080}, {L"green", 0xff008000},
- {L"grey", 0xff808080}, {L"lime", 0xff00ff00}, {L"maroon", 0xff800000},
- {L"navy", 0xff000080}, {L"olive", 0xff808000}, {L"orange", 0xffffa500},
- {L"purple", 0xff800080}, {L"red", 0xffff0000}, {L"silver", 0xffc0c0c0},
- {L"teal", 0xff008080}, {L"white", 0xffffffff}, {L"yellow", 0xffffff00},
+ {"aqua", 0xff00ffff}, {"black", 0xff000000}, {"blue", 0xff0000ff},
+ {"fuchsia", 0xffff00ff}, {"gray", 0xff808080}, {"green", 0xff008000},
+ {"grey", 0xff808080}, {"lime", 0xff00ff00}, {"maroon", 0xff800000},
+ {"navy", 0xff000080}, {"olive", 0xff808000}, {"orange", 0xffffa500},
+ {"purple", 0xff800080}, {"red", 0xffff0000}, {"silver", 0xffc0c0c0},
+ {"teal", 0xff008080}, {"white", 0xffffffff}, {"yellow", 0xffffff00},
};
} // namespace
@@ -101,30 +101,24 @@
const CFX_CSSData::LengthUnit* CFX_CSSData::GetLengthUnitByName(
WideStringView wsName) {
- if (wsName.IsEmpty() || wsName.GetLength() != 2)
+ if (wsName.IsEmpty() || wsName.GetLength() != 2) {
return nullptr;
-
- WideString lowerName = WideString(wsName);
- lowerName.MakeLower();
-
+ }
auto* iter =
std::find_if(std::begin(kLengthUnitTable), std::end(kLengthUnitTable),
- [lowerName](const CFX_CSSData::LengthUnit& unit) {
- return lowerName == unit.value;
+ [wsName](const CFX_CSSData::LengthUnit& unit) {
+ return wsName.EqualsASCIINoCase(unit.value);
});
return iter != std::end(kLengthUnitTable) ? iter : nullptr;
}
const CFX_CSSData::Color* CFX_CSSData::GetColorByName(WideStringView wsName) {
- if (wsName.IsEmpty())
+ if (wsName.IsEmpty()) {
return nullptr;
-
- WideString lowerName = WideString(wsName);
- lowerName.MakeLower();
-
+ }
auto* iter = std::find_if(std::begin(kColorTable), std::end(kColorTable),
- [lowerName](const CFX_CSSData::Color& color) {
- return lowerName == color.name;
+ [wsName](const CFX_CSSData::Color& color) {
+ return wsName.EqualsASCIINoCase(color.name);
});
return iter != std::end(kColorTable) ? iter : nullptr;
}
diff --git a/core/fxcrt/css/cfx_cssdata.h b/core/fxcrt/css/cfx_cssdata.h
index af21c5a..d342be3 100644
--- a/core/fxcrt/css/cfx_cssdata.h
+++ b/core/fxcrt/css/cfx_cssdata.h
@@ -27,12 +27,12 @@
};
struct LengthUnit {
- const wchar_t* value; // Raw, POD struct.
+ const char* value; // Raw, POD struct.
CFX_CSSNumber::Unit type;
};
struct Color {
- const wchar_t* name; // Raw, POD struct.
+ const char* name; // Raw, POD struct.
FX_ARGB value;
};
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp
index 5d19777..15c42f3 100644
--- a/core/fxcrt/xml/cfx_xmlparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -509,15 +509,15 @@
if (character != 0)
current_text_ += character;
} else {
- if (csEntity == L"amp") {
+ if (csEntity.EqualsASCII("amp")) {
current_text_ += L'&';
- } else if (csEntity == L"lt") {
+ } else if (csEntity.EqualsASCII("lt")) {
current_text_ += L'<';
- } else if (csEntity == L"gt") {
+ } else if (csEntity.EqualsASCII("gt")) {
current_text_ += L'>';
- } else if (csEntity == L"apos") {
+ } else if (csEntity.EqualsASCII("apos")) {
current_text_ += L'\'';
- } else if (csEntity == L"quot") {
+ } else if (csEntity.EqualsASCII("quot")) {
current_text_ += L'"';
}
}
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index 9005431..8468cd3 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -193,7 +193,7 @@
void SetCurrentPage(int iCurPage);
// TODO(dsinclair): This should probably change to PDFium?
- WideString FFI_GetAppName() const { return WideString(L"Acrobat"); }
+ WideString FFI_GetAppName() const { return WideString::FromASCII("Acrobat"); }
void GotoURL(const WideString& wsURL);
FS_RECTF GetPageViewRect(IPDF_Page* page);
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index 5c21df6..ad94b24 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -321,7 +321,7 @@
}
WideString CPDFXFA_Context::GetAppTitle() const {
- return L"PDFium";
+ return WideString::FromASCII("PDFium");
}
WideString CPDFXFA_Context::GetAppName() {
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index 29aabe2..00c4ab0 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -499,10 +499,11 @@
}
WideString CJS_App::SysPathToPDFPath(const WideString& sOldPath) {
- WideString sRet = L"/";
+ auto sRet = WideString::FromASCII("/");
for (const wchar_t& c : sOldPath) {
- if (c != L':')
+ if (c != L':') {
sRet += (c == L'\\') ? L'/' : c;
+ }
}
return sRet;
}
@@ -527,7 +528,7 @@
return CJS_Result::Failure(JSMessage::kParamError);
WideString swQuestion = pRuntime->ToWideString(newParams[0]);
- WideString swTitle = L"PDF";
+ auto swTitle = WideString::FromASCII("PDF");
if (IsExpandedParamKnown(newParams[1]))
swTitle = pRuntime->ToWideString(newParams[1]);
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index e37cf01..c303efc 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -363,8 +363,9 @@
CPDFSDK_InteractiveForm* pInteractiveForm = GetSDKInteractiveForm();
ByteString sTextBuf = pInteractiveForm->ExportFormToFDFTextBuf();
- if (sTextBuf.IsEmpty())
- return CJS_Result::Failure(L"Bad FDF format.");
+ if (sTextBuf.IsEmpty()) {
+ return CJS_Result::Failure(WideString::FromASCII("Bad FDF format."));
+ }
v8::LocalVector<v8::Value> newParams = ExpandKeywordParams(
pRuntime, params, 6, "bUI", "cTo", "cCc", "cBcc", "cSubject", "cMsg");
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index 6b89038..594b74a 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -91,9 +91,9 @@
CJS_Result CJS_Event::get_field_full(CJS_Runtime* pRuntime) {
CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
- if (pEvent->Name() != "Keystroke")
- return CJS_Result::Failure(L"unrecognized event");
-
+ if (pEvent->Name() != "Keystroke") {
+ return CJS_Result::Failure(WideString::FromASCII("unrecognized event"));
+ }
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->FieldFull()));
}
@@ -259,12 +259,12 @@
CJS_Result CJS_Event::get_value(CJS_Runtime* pRuntime) {
CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
- if (pEvent->Type() != "Field")
- return CJS_Result::Failure(L"Bad event type.");
-
- if (!pEvent->HasValue())
+ if (pEvent->Type() != "Field") {
+ return CJS_Result::Failure(WideString::FromASCII("Bad event type."));
+ }
+ if (!pEvent->HasValue()) {
return CJS_Result::Failure(JSMessage::kBadObjectError);
-
+ }
return CJS_Result::Success(
pRuntime->NewString(pEvent->Value().AsStringView()));
}
@@ -272,18 +272,18 @@
CJS_Result CJS_Event::set_value(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
- if (pEvent->Type() != "Field")
- return CJS_Result::Failure(L"Bad event type.");
-
- if (!pEvent->HasValue())
+ if (pEvent->Type() != "Field") {
+ return CJS_Result::Failure(WideString::FromASCII("Bad event type."));
+ }
+ if (!pEvent->HasValue()) {
return CJS_Result::Failure(JSMessage::kBadObjectError);
-
- if (vp.IsEmpty())
+ }
+ if (vp.IsEmpty()) {
return CJS_Result::Failure(JSMessage::kBadObjectError);
-
- if (vp->IsNullOrUndefined() || vp->IsBoolean())
+ }
+ if (vp->IsNullOrUndefined() || vp->IsBoolean()) {
return CJS_Result::Failure(JSMessage::kInvalidSetError);
-
+ }
pEvent->Value() = pRuntime->ToWideString(vp);
return CJS_Result::Success();
}
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 6162b52..784b572 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -2146,7 +2146,7 @@
if (!pFormField->CountControls())
return CJS_Result::Failure(JSMessage::kBadObjectError);
return CJS_Result::Success(pRuntime->NewString(
- pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off"));
+ pFormField->GetControl(0)->IsChecked() ? "Yes" : "Off"));
}
if (pFormField->GetFieldType() == FormFieldType::kRadioButton &&
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 379bed7..aeaf0ad 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -73,23 +73,13 @@
constexpr double kDoubleCorrect = 0.000000000000001;
#endif
-constexpr const wchar_t* kDateFormats[] = {L"m/d",
- L"m/d/yy",
- L"mm/dd/yy",
- L"mm/yy",
- L"d-mmm",
- L"d-mmm-yy",
- L"dd-mmm-yy",
- L"yy-mm-dd",
- L"mmm-yy",
- L"mmmm-yy",
- L"mmm d, yyyy",
- L"mmmm d, yyyy",
- L"m/d/yy h:MM tt",
- L"m/d/yy HH:MM"};
+constexpr const char* kDateFormats[] = {
+ "m/d", "m/d/yy", "mm/dd/yy", "mm/yy", "d-mmm",
+ "d-mmm-yy", "dd-mmm-yy", "yy-mm-dd", "mmm-yy", "mmmm-yy",
+ "mmm d, yyyy", "mmmm d, yyyy", "m/d/yy h:MM tt", "m/d/yy HH:MM"};
-constexpr const wchar_t* kTimeFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
- L"h:MM:ss tt"};
+constexpr const char* kTimeFormats[] = {"HH:MM", "h:MM tt", "HH:MM:ss",
+ "h:MM:ss tt"};
template <typename T>
T StrTrim(const T& str) {
@@ -720,7 +710,8 @@
if (!IsNumber(swTemp)) {
pContext->Rc() = false;
WideString sError = JSGetStringFromID(JSMessage::kInvalidInputError);
- AlertIfPossible(pContext, L"AFNumber_Keystroke", sError);
+ AlertIfPossible(pContext, WideString::FromASCII("AFNumber_Keystroke"),
+ sError);
return CJS_Result::Failure(sError);
}
// It happens after the last keystroke and before validating,
@@ -907,7 +898,7 @@
if (isnan(dDate)) {
WideString swMsg = WideString::Format(
JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str());
- AlertIfPossible(pEvent, L"AFDate_FormatEx", swMsg);
+ AlertIfPossible(pEvent, WideString::FromASCII("AFDate_FormatEx"), swMsg);
return CJS_Result::Failure(JSMessage::kParseDateError);
}
@@ -979,7 +970,7 @@
if (bWrongFormat || isnan(dRet)) {
WideString swMsg = WideString::Format(
JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str());
- AlertIfPossible(pEvent, L"AFDate_KeystrokeEx", swMsg);
+ AlertIfPossible(pEvent, WideString::FromASCII("AFDate_KeystrokeEx"), swMsg);
pEvent->Rc() = false;
}
return CJS_Result::Success();
@@ -1066,19 +1057,19 @@
WideString wsFormat;
switch (pRuntime->ToInt32(params[0])) {
case 0:
- wsFormat = L"99999";
+ wsFormat = WideString::FromASCII("99999");
break;
case 1:
- wsFormat = L"99999-9999";
+ wsFormat = WideString::FromASCII("99999-9999");
break;
case 2:
if (CJS_Util::StringPrintx(L"9999999999", wsSource).GetLength() >= 10)
- wsFormat = L"(999) 999-9999";
+ wsFormat = WideString::FromASCII("(999) 999-9999");
else
- wsFormat = L"999-9999";
+ wsFormat = WideString::FromASCII("999-9999");
break;
case 3:
- wsFormat = L"999-99-9999";
+ wsFormat = WideString::FromASCII("999-99-9999");
break;
}
@@ -1107,7 +1098,7 @@
return CJS_Result::Success();
if (valEvent.GetLength() > wstrMask.GetLength()) {
- AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, WideString::FromASCII("AFSpecial_KeystrokeEx"),
JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
return CJS_Result::Success();
@@ -1119,7 +1110,7 @@
break;
}
if (iIndex != wstrMask.GetLength()) {
- AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, WideString::FromASCII("AFSpecial_KeystrokeEx"),
JSGetStringFromID(JSMessage::kInvalidInputError));
pEvent->Rc() = false;
}
@@ -1135,14 +1126,14 @@
size_t combined_len = valEvent.GetLength() + wChange.GetLength() +
pEvent->SelStart() - pEvent->SelEnd();
if (combined_len > wstrMask.GetLength()) {
- AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, WideString::FromASCII("AFSpecial_KeystrokeEx"),
JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
return CJS_Result::Success();
}
if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) {
- AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, WideString::FromASCII("AFSpecial_KeystrokeEx"),
JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
return CJS_Result::Success();
@@ -1150,7 +1141,7 @@
for (size_t i = 0; i < wChange.GetLength(); ++i) {
if (iIndexMask >= wstrMask.GetLength()) {
- AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, WideString::FromASCII("AFSpecial_KeystrokeEx"),
JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
return CJS_Result::Success();
@@ -1236,8 +1227,8 @@
if (isnan(dDate)) {
WideString swMsg = WideString::Format(
JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str());
- AlertIfPossible(pRuntime->GetCurrentEventContext(), L"AFParseDateEx",
- swMsg);
+ AlertIfPossible(pRuntime->GetCurrentEventContext(),
+ WideString::FromASCII("AFParseDateEx"), swMsg);
return CJS_Result::Failure(JSMessage::kParseDateError);
}
return CJS_Result::Success(pRuntime->NewNumber(dDate));
@@ -1260,9 +1251,9 @@
return CJS_Result::Failure(JSMessage::kValueError);
double dValue = result.value();
- if (wcscmp(sFunction.c_str(), L"AVG") == 0)
+ if (sFunction.EqualsASCII("AVG")) {
dValue /= 2.0;
-
+ }
return CJS_Result::Success(pRuntime->NewNumber(dValue));
}
@@ -1300,7 +1291,7 @@
pRuntime->GetFormFillEnv()->GetInteractiveForm();
CPDF_InteractiveForm* pForm = pReaderForm->GetInteractiveForm();
- double dValue = wcscmp(sFunction.c_str(), L"PRD") == 0 ? 1.0 : 0.0;
+ double dValue = sFunction.EqualsASCII("PRD") ? 1.0 : 0.0;
int nFieldsCount = 0;
for (size_t i = 0; i < pRuntime->GetArrayLength(FieldNameArray); ++i) {
WideString wsFieldName =
@@ -1350,8 +1341,7 @@
}
if (i == 0 && j == 0 &&
- (wcscmp(sFunction.c_str(), L"MIN") == 0 ||
- wcscmp(sFunction.c_str(), L"MAX") == 0)) {
+ (sFunction.EqualsASCII("MIN") || sFunction.EqualsASCII("MAX"))) {
dValue = dTemp;
}
std::optional<double> dResult =
@@ -1364,9 +1354,9 @@
}
}
- if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0)
+ if (sFunction.EqualsASCII("AVG") && nFieldsCount > 0) {
dValue /= nFieldsCount;
-
+ }
dValue = floor(dValue * powf(10, 6) + 0.49) / powf(10, 6);
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
@@ -1417,7 +1407,7 @@
}
if (!swMsg.IsEmpty()) {
- AlertIfPossible(pEvent, L"AFRange_Validate", swMsg);
+ AlertIfPossible(pEvent, WideString::FromASCII("AFRange_Validate"), swMsg);
pEvent->Rc() = false;
}
return CJS_Result::Success();
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp
index 616e84f..f975202 100644
--- a/fxjs/xfa/cfxjse_engine.cpp
+++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -535,16 +535,16 @@
const v8::FunctionCallbackInfo<v8::Value>& info,
const WideString& functionName) {
CXFA_Object* pObject = ToObject(info);
- if (!pObject)
- return CJS_Result::Failure(L"no Holder() present.");
-
+ if (!pObject) {
+ return CJS_Result::Failure(WideString::FromASCII("no Holder() present."));
+ }
CFXJSE_Engine* pScriptContext = pObject->GetDocument()->GetScriptContext();
pObject = pScriptContext->GetVariablesThis(pObject);
v8::LocalVector<v8::Value> parameters(info.GetIsolate());
- for (int i = 0; i < info.Length(); i++)
+ for (int i = 0; i < info.Length(); i++) {
parameters.push_back(info[i]);
-
+ }
return pObject->JSObject()->RunMethod(pScriptContext, functionName,
parameters);
}
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index a18d00c..18c2534 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -347,27 +347,35 @@
std::pair<bool, CXFA_LocaleValue::ValueType> PatternStringType(
ByteStringView bsPattern) {
WideString wsPattern = WideString::FromUTF8(bsPattern);
- if (L"datetime" == wsPattern.First(8))
+ if (wsPattern.First(8).EqualsASCII("datetime")) {
return {true, CXFA_LocaleValue::ValueType::kDateTime};
- if (L"date" == wsPattern.First(4)) {
+ }
+ if (wsPattern.First(4).EqualsASCII("date")) {
auto pos = wsPattern.Find(L"time");
- if (pos.has_value() && pos.value() != 0)
+ if (pos.has_value() && pos.value() != 0) {
return {true, CXFA_LocaleValue::ValueType::kDateTime};
+ }
return {true, CXFA_LocaleValue::ValueType::kDate};
}
- if (L"time" == wsPattern.First(4))
+ if (wsPattern.First(4).EqualsASCII("time")) {
return {true, CXFA_LocaleValue::ValueType::kTime};
- if (L"text" == wsPattern.First(4))
+ }
+ if (wsPattern.First(4).EqualsASCII("text")) {
return {true, CXFA_LocaleValue::ValueType::kText};
- if (L"num" == wsPattern.First(3)) {
- if (L"integer" == wsPattern.Substr(4, 7))
+ }
+ if (wsPattern.First(3).EqualsASCII("num")) {
+ if (wsPattern.Substr(4, 7).EqualsASCII("integer")) {
return {true, CXFA_LocaleValue::ValueType::kInteger};
- if (L"decimal" == wsPattern.Substr(4, 7))
+ }
+ if (wsPattern.Substr(4, 7).EqualsASCII("decimal")) {
return {true, CXFA_LocaleValue::ValueType::kDecimal};
- if (L"currency" == wsPattern.Substr(4, 8))
+ }
+ if (wsPattern.Substr(4, 8).EqualsASCII("currency")) {
return {true, CXFA_LocaleValue::ValueType::kFloat};
- if (L"percent" == wsPattern.Substr(4, 7))
+ }
+ if (wsPattern.Substr(4, 7).EqualsASCII("percent")) {
return {true, CXFA_LocaleValue::ValueType::kFloat};
+ }
return {true, CXFA_LocaleValue::ValueType::kFloat};
}
@@ -3481,10 +3489,10 @@
info.GetReturnValue().SetEmptyString();
return;
}
- WideString wsDatePattern(L"date{");
+ auto wsDatePattern = WideString::FromASCII("date{");
wsDatePattern += wsPattern.First(iTChar.value()) + L"} ";
- WideString wsTimePattern(L"time{");
+ auto wsTimePattern = WideString::FromASCII("time{");
wsTimePattern +=
wsPattern.Last(wsPattern.GetLength() - (iTChar.value() + 1)) + L"}";
wsPattern = wsDatePattern + wsTimePattern;
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 8f69350..179a313 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -541,7 +541,7 @@
CXFA_Node* pChildValue = pValue->GetFirstChild();
pChildValue->JSObject()->SetCData(XFA_Attribute::ContentType,
- L"text/xml");
+ WideString::FromASCII("text/xml"));
pChildValue->JSObject()->SetContent(wsContent, wsContent, bNotify,
bScriptModify, false);
@@ -563,8 +563,8 @@
while (iAddNodes-- > 0) {
CXFA_Node* pValueNodes =
pBind->CreateSamePacketNode(XFA_Element::DataValue);
- pValueNodes->JSObject()->SetCData(XFA_Attribute::Name,
- L"value");
+ pValueNodes->JSObject()->SetCData(
+ XFA_Attribute::Name, WideString::FromASCII("value"));
pValueNodes->CreateXMLMappingNode();
pBind->InsertChildAndNotify(pValueNodes, nullptr);
}
@@ -705,7 +705,8 @@
CXFA_Node* pChildValue = pValue->GetFirstChild();
if (pChildValue && XFA_FieldIsMultiListBox(GetXFANode())) {
pChildValue->JSObject()->SetAttributeByEnum(
- XFA_Attribute::ContentType, L"text/xml", false);
+ XFA_Attribute::ContentType, WideString::FromASCII("text/xml"),
+ false);
}
if (!pChildValue)
return std::nullopt;
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
index 89668b5..4ec5c05 100644
--- a/fxjs/xfa/cjx_tree.cpp
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -128,8 +128,7 @@
bool bSetting,
XFA_Attribute eAttribute) {
if (bSetting) {
- WideString wsMessage = L"Unable to set ";
- FXJSE_ThrowMessage(pIsolate, wsMessage.ToUTF8().AsStringView());
+ FXJSE_ThrowMessage(pIsolate, "Unable to set ");
return;
}
diff --git a/xfa/fwl/cfwl_checkbox.cpp b/xfa/fwl/cfwl_checkbox.cpp
index ee78201..fbe0280 100644
--- a/xfa/fwl/cfwl_checkbox.cpp
+++ b/xfa/fwl/cfwl_checkbox.cpp
@@ -82,7 +82,7 @@
textParam.m_dwStates = dwStates;
textParam.m_matrix = matrix;
textParam.m_PartRect = m_CaptionRect;
- textParam.m_wsText = L"Check box";
+ textParam.m_wsText = WideString::FromASCII("Check box");
textParam.m_dwTTOStyles = m_TTOStyles;
textParam.m_iTTOAlign = m_iTTOAlign;
pTheme->DrawText(textParam);
@@ -117,7 +117,8 @@
m_CaptionRect.Inflate(-kCaptionMargin, -kCaptionMargin);
CFX_RectF rtFocus = m_CaptionRect;
- CalcTextRect(L"Check box", m_TTOStyles, m_iTTOAlign, &rtFocus);
+ CalcTextRect(WideString::FromASCII("Check box"), m_TTOStyles, m_iTTOAlign,
+ &rtFocus);
m_FocusRect = CFX_RectF(m_CaptionRect.TopLeft(),
std::max(m_CaptionRect.width, rtFocus.width),
std::min(m_CaptionRect.height, rtFocus.height));
diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp
index e286fd0..df422bf 100644
--- a/xfa/fwl/cfwl_monthcalendar.cpp
+++ b/xfa/fwl/cfwl_monthcalendar.cpp
@@ -36,19 +36,19 @@
WideString GetAbbreviatedDayOfWeek(int day) {
switch (day) {
case 0:
- return L"Sun";
+ return WideString::FromASCII("Sun");
case 1:
- return L"Mon";
+ return WideString::FromASCII("Mon");
case 2:
- return L"Tue";
+ return WideString::FromASCII("Tue");
case 3:
- return L"Wed";
+ return WideString::FromASCII("Wed");
case 4:
- return L"Thu";
+ return WideString::FromASCII("Thu");
case 5:
- return L"Fri";
+ return WideString::FromASCII("Fri");
case 6:
- return L"Sat";
+ return WideString::FromASCII("Sat");
default:
NOTREACHED_NORETURN();
}
@@ -57,29 +57,29 @@
WideString GetMonth(int month) {
switch (month) {
case 0:
- return L"January";
+ return WideString::FromASCII("January");
case 1:
- return L"February";
+ return WideString::FromASCII("February");
case 2:
- return L"March";
+ return WideString::FromASCII("March");
case 3:
- return L"April";
+ return WideString::FromASCII("April");
case 4:
- return L"May";
+ return WideString::FromASCII("May");
case 5:
- return L"June";
+ return WideString::FromASCII("June");
case 6:
- return L"July";
+ return WideString::FromASCII("July");
case 7:
- return L"August";
+ return WideString::FromASCII("August");
case 8:
- return L"September";
+ return WideString::FromASCII("September");
case 9:
- return L"October";
+ return WideString::FromASCII("October");
case 10:
- return L"November";
+ return WideString::FromASCII("November");
case 11:
- return L"December";
+ return WideString::FromASCII("December");
default:
NOTREACHED_NORETURN();
}