summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-20 16:10:13 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-20 16:10:13 +0000
commitb6b01cb2cbaf6b38736f4dfebb9b6cdc243960f9 (patch)
tree3219404f5dbafe19205ce85d19acaf3b1178f977 /fxjs
parentb3345feca2741cef2073d18da414237589528dd0 (diff)
downloadpdfium-b6b01cb2cbaf6b38736f4dfebb9b6cdc243960f9.tar.xz
Re-work some more c_str() usage.
Many of these are converting ByteString => c_str => ByteStringView, since the ByteStringView ctor is implicit. This is unfortunate, since that involves a strlen() which the ByteString already knows if we use AsStringView() instead. This changed one test result where we can now return the string "\0" instead of "" -- since strlen no longer eats the NUL. This seems consistent, say, with String.fromCharCode(). Change-Id: I17f68d1a1f4b352960208f9148e68ab4c4d78bd2 Reviewed-on: https://pdfium-review.googlesource.com/35590 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cjs_annot.cpp8
-rw-r--r--fxjs/cjs_app.cpp10
-rw-r--r--fxjs/cjs_document.cpp15
-rw-r--r--fxjs/cjs_event.cpp12
-rw-r--r--fxjs/cjs_field.cpp58
-rw-r--r--fxjs/cjs_global.cpp2
-rw-r--r--fxjs/cjs_icon.cpp2
-rw-r--r--fxjs/cjs_publicmethods.cpp19
-rw-r--r--fxjs/cjs_util.cpp2
9 files changed, 65 insertions, 63 deletions
diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp
index 8a53ebc048..49db20475a 100644
--- a/fxjs/cjs_annot.cpp
+++ b/fxjs/cjs_annot.cpp
@@ -81,8 +81,8 @@ CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime,
CJS_Return CJS_Annot::get_name(CJS_Runtime* pRuntime) {
if (!m_pAnnot)
return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(
- pRuntime->NewString(ToBAAnnot(m_pAnnot.Get())->GetAnnotName().c_str()));
+ return CJS_Return(pRuntime->NewString(
+ ToBAAnnot(m_pAnnot.Get())->GetAnnotName().AsStringView()));
}
CJS_Return CJS_Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
@@ -101,8 +101,8 @@ CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(
WideString::FromLocal(CPDF_Annot::AnnotSubtypeToString(
ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype())
- .c_str())
- .c_str()));
+ .AsStringView())
+ .AsStringView()));
}
CJS_Return CJS_Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index 61eb632939..36a1212715 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -176,9 +176,9 @@ CJS_Return CJS_App::get_platform(CJS_Runtime* pRuntime) {
if (!pFormFillEnv)
return CJS_Return(JSMessage::kBadObjectError);
- WideString platfrom = pFormFillEnv->GetPlatform();
- if (!platfrom.IsEmpty())
- return CJS_Return(pRuntime->NewString(platfrom.c_str()));
+ WideString platform = pFormFillEnv->GetPlatform();
+ if (!platform.IsEmpty())
+ return CJS_Return(pRuntime->NewString(platform.AsStringView()));
#endif
return CJS_Return(pRuntime->NewString(JS_STR_PLATFORM));
}
@@ -196,7 +196,7 @@ CJS_Return CJS_App::get_language(CJS_Runtime* pRuntime) {
WideString language = pFormFillEnv->GetLanguage();
if (!language.IsEmpty())
- return CJS_Return(pRuntime->NewString(language.c_str()));
+ return CJS_Return(pRuntime->NewString(language.AsStringView()));
#endif
return CJS_Return(pRuntime->NewString(JS_STR_LANGUAGE));
}
@@ -572,7 +572,7 @@ CJS_Return CJS_App::response(CJS_Runtime* pRuntime,
return CJS_Return(pRuntime->NewString(
WideString::FromUTF16LE(reinterpret_cast<uint16_t*>(pBuff.data()),
nLengthBytes / sizeof(uint16_t))
- .c_str()));
+ .AsStringView()));
}
CJS_Return CJS_App::get_media(CJS_Runtime* pRuntime) {
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index 74304bba1d..b22d31b0b4 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -279,7 +279,7 @@ CJS_Return CJS_Document::getNthFieldName(
CPDF_FormField* pField = pPDFForm->GetField(nIndex, WideString());
if (!pField)
return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(pField->GetFullName().c_str()));
+ return CJS_Return(pRuntime->NewString(pField->GetFullName().AsStringView()));
}
CJS_Return CJS_Document::importAnFDF(
@@ -719,8 +719,8 @@ CJS_Return CJS_Document::getPropertyInternal(CJS_Runtime* pRuntime,
CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(
- pRuntime->NewString(pDictionary->GetUnicodeTextFor(propName).c_str()));
+ return CJS_Return(pRuntime->NewString(
+ pDictionary->GetUnicodeTextFor(propName).AsStringView()));
}
CJS_Return CJS_Document::setPropertyInternal(CJS_Runtime* pRuntime,
@@ -889,7 +889,7 @@ CJS_Return CJS_Document::get_URL(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(
- pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().c_str()));
+ pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().AsStringView()));
}
CJS_Return CJS_Document::set_URL(CJS_Runtime* pRuntime,
@@ -898,7 +898,7 @@ CJS_Return CJS_Document::set_URL(CJS_Runtime* pRuntime,
}
CJS_Return CJS_Document::get_base_URL(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewString(m_cwBaseURL.c_str()));
+ return CJS_Return(pRuntime->NewString(m_cwBaseURL.AsStringView()));
}
CJS_Return CJS_Document::set_base_URL(CJS_Runtime* pRuntime,
@@ -950,7 +950,8 @@ CJS_Return CJS_Document::get_path(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(pRuntime->NewString(
- CJS_App::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()).c_str()));
+ CJS_App::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath())
+ .AsStringView()));
}
CJS_Return CJS_Document::set_path(CJS_Runtime* pRuntime,
@@ -1269,7 +1270,7 @@ CJS_Return CJS_Document::getPageNthWord(
if (bStrip)
swRet.Trim();
- return CJS_Return(pRuntime->NewString(swRet.c_str()));
+ return CJS_Return(pRuntime->NewString(swRet.AsStringView()));
}
CJS_Return CJS_Document::getPageNthWordQuads(
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index 397d8b890c..c10f8858a9 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -51,10 +51,9 @@ CJS_Event::~CJS_Event() = default;
CJS_Return CJS_Event::get_change(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->Change().c_str()));
+ return CJS_Return(pRuntime->NewString(pEvent->Change().AsStringView()));
}
CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
@@ -73,11 +72,10 @@ CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
CJS_Return CJS_Event::get_change_ex(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().c_str()));
+ return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().AsStringView()));
}
CJS_Return CJS_Event::set_change_ex(CJS_Runtime* pRuntime,
@@ -256,7 +254,6 @@ CJS_Return CJS_Event::set_source(CJS_Runtime* pRuntime,
CJS_Return CJS_Event::get_target(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pEvent->Target_Field()->ToV8Object());
@@ -269,10 +266,9 @@ CJS_Return CJS_Event::set_target(CJS_Runtime* pRuntime,
CJS_Return CJS_Event::get_target_name(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->TargetName().c_str()));
+ return CJS_Return(pRuntime->NewString(pEvent->TargetName().AsStringView()));
}
CJS_Return CJS_Event::set_target_name(CJS_Runtime* pRuntime,
@@ -304,7 +300,7 @@ CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) {
if (!pEvent->m_pValue)
return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(pEvent->Value().c_str()));
+ return CJS_Return(pRuntime->NewString(pEvent->Value().AsStringView()));
}
CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime,
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index e9aa777df8..84835866ea 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -890,7 +890,8 @@ CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) {
return CJS_Return(JSMessage::kObjectTypeError);
}
- return CJS_Return(pRuntime->NewString(pFormField->GetDefaultValue().c_str()));
+ return CJS_Return(
+ pRuntime->NewString(pFormField->GetDefaultValue().AsStringView()));
}
CJS_Return CJS_Field::set_default_value(CJS_Runtime* pRuntime,
@@ -1092,7 +1093,7 @@ CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) {
CPDF_FormControl* pFormControl = pFormField->GetControl(i);
pRuntime->PutArrayElement(
ExportValuesArray, i,
- pRuntime->NewString(pFormControl->GetExportValue().c_str()));
+ pRuntime->NewString(pFormControl->GetExportValue().AsStringView()));
}
} else {
if (m_nFormControlIndex >= pFormField->CountControls())
@@ -1105,7 +1106,7 @@ CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) {
pRuntime->PutArrayElement(
ExportValuesArray, 0,
- pRuntime->NewString(pFormControl->GetExportValue().c_str()));
+ pRuntime->NewString(pFormControl->GetExportValue().AsStringView()));
}
return CJS_Return(ExportValuesArray);
}
@@ -1420,7 +1421,7 @@ CJS_Return CJS_Field::get_name(CJS_Runtime* pRuntime) {
if (FieldArray.empty())
return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(m_FieldName.c_str()));
+ return CJS_Return(pRuntime->NewString(m_FieldName.AsStringView()));
}
CJS_Return CJS_Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
@@ -1903,8 +1904,8 @@ CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) {
csBCaption = "check";
break;
}
- return CJS_Return(
- pRuntime->NewString(WideString::FromLocal(csBCaption.c_str()).c_str()));
+ return CJS_Return(pRuntime->NewString(
+ WideString::FromLocal(csBCaption.AsStringView()).AsStringView()));
}
CJS_Return CJS_Field::set_style(CJS_Runtime* pRuntime,
@@ -1993,7 +1994,8 @@ CJS_Return CJS_Field::get_text_font(CJS_Runtime* pRuntime) {
return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(pRuntime->NewString(
- WideString::FromLocal(pFont->GetBaseFont().c_str()).c_str()));
+ WideString::FromLocal(pFont->GetBaseFont().AsStringView())
+ .AsStringView()));
}
CJS_Return CJS_Field::set_text_font(CJS_Runtime* pRuntime,
@@ -2074,7 +2076,7 @@ CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) {
return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(
- pRuntime->NewString(FieldArray[0]->GetAlternateName().c_str()));
+ pRuntime->NewString(FieldArray[0]->GetAlternateName().AsStringView()));
}
CJS_Return CJS_Field::set_user_name(CJS_Runtime* pRuntime,
@@ -2098,7 +2100,7 @@ CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) {
return CJS_Return(JSMessage::kObjectTypeError);
case FormFieldType::kComboBox:
case FormFieldType::kTextField:
- ret = pRuntime->NewString(pFormField->GetValue().c_str());
+ ret = pRuntime->NewString(pFormField->GetValue().AsStringView());
break;
case FormFieldType::kListBox: {
if (pFormField->CountSelectedItems() > 1) {
@@ -2107,17 +2109,17 @@ CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) {
int iIndex;
for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
iIndex = pFormField->GetSelectedIndex(i);
- ElementValue =
- pRuntime->NewString(pFormField->GetOptionValue(iIndex).c_str());
+ ElementValue = pRuntime->NewString(
+ pFormField->GetOptionValue(iIndex).AsStringView());
if (wcslen(pRuntime->ToWideString(ElementValue).c_str()) == 0) {
- ElementValue =
- pRuntime->NewString(pFormField->GetOptionLabel(iIndex).c_str());
+ ElementValue = pRuntime->NewString(
+ pFormField->GetOptionLabel(iIndex).AsStringView());
}
pRuntime->PutArrayElement(ValueArray, i, ElementValue);
}
ret = ValueArray;
} else {
- ret = pRuntime->NewString(pFormField->GetValue().c_str());
+ ret = pRuntime->NewString(pFormField->GetValue().AsStringView());
}
break;
}
@@ -2127,7 +2129,7 @@ CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) {
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
if (pFormField->GetControl(i)->IsChecked()) {
ret = pRuntime->NewString(
- pFormField->GetControl(i)->GetExportValue().c_str());
+ pFormField->GetControl(i)->GetExportValue().AsStringView());
bFind = true;
break;
}
@@ -2138,7 +2140,7 @@ CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) {
break;
}
default:
- ret = pRuntime->NewString(pFormField->GetValue().c_str());
+ ret = pRuntime->NewString(pFormField->GetValue().AsStringView());
break;
}
return CJS_Return(pRuntime->MaybeCoerceToNumber(ret));
@@ -2245,7 +2247,7 @@ CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) {
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
if (pFormField->GetControl(i)->IsChecked()) {
return CJS_Return(pRuntime->NewString(
- pFormField->GetControl(i)->GetExportValue().c_str()));
+ pFormField->GetControl(i)->GetExportValue().AsStringView()));
}
}
return CJS_Return(pRuntime->NewString(L"Off"));
@@ -2255,7 +2257,7 @@ CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) {
(pFormField->CountSelectedItems() > 1)) {
return CJS_Return(pRuntime->NewString(L""));
}
- return CJS_Return(pRuntime->NewString(pFormField->GetValue().c_str()));
+ return CJS_Return(pRuntime->NewString(pFormField->GetValue().AsStringView()));
}
CJS_Return CJS_Field::set_value_as_string(CJS_Runtime* pRuntime,
@@ -2305,13 +2307,15 @@ CJS_Return CJS_Field::buttonGetCaption(
if (nface == 0) {
return CJS_Return(
- pRuntime->NewString(pFormControl->GetNormalCaption().c_str()));
- } else if (nface == 1) {
+ pRuntime->NewString(pFormControl->GetNormalCaption().AsStringView()));
+ }
+ if (nface == 1) {
return CJS_Return(
- pRuntime->NewString(pFormControl->GetDownCaption().c_str()));
- } else if (nface == 2) {
+ pRuntime->NewString(pFormControl->GetDownCaption().AsStringView()));
+ }
+ if (nface == 2) {
return CJS_Return(
- pRuntime->NewString(pFormControl->GetRolloverCaption().c_str()));
+ pRuntime->NewString(pFormControl->GetRolloverCaption().AsStringView()));
}
return CJS_Return(JSMessage::kValueError);
}
@@ -2496,13 +2500,13 @@ CJS_Return CJS_Field::getItemAt(
if (bExport) {
WideString strval = pFormField->GetOptionValue(nIdx);
if (strval.IsEmpty()) {
- return CJS_Return(
- pRuntime->NewString(pFormField->GetOptionLabel(nIdx).c_str()));
+ return CJS_Return(pRuntime->NewString(
+ pFormField->GetOptionLabel(nIdx).AsStringView()));
}
- return CJS_Return(pRuntime->NewString(strval.c_str()));
+ return CJS_Return(pRuntime->NewString(strval.AsStringView()));
}
return CJS_Return(
- pRuntime->NewString(pFormField->GetOptionLabel(nIdx).c_str()));
+ pRuntime->NewString(pFormField->GetOptionLabel(nIdx).AsStringView()));
}
return CJS_Return(JSMessage::kObjectTypeError);
}
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 977d916492..e9b2a4b8f0 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -248,7 +248,7 @@ CJS_Return CJS_Global::GetProperty(CJS_Runtime* pRuntime,
return CJS_Return(pRuntime->NewBoolean(pData->bData));
case JS_GlobalDataType::STRING:
return CJS_Return(pRuntime->NewString(
- WideString::FromLocal(pData->sData.c_str()).c_str()));
+ WideString::FromLocal(pData->sData.AsStringView()).AsStringView()));
case JS_GlobalDataType::OBJECT:
return CJS_Return(
v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData));
diff --git a/fxjs/cjs_icon.cpp b/fxjs/cjs_icon.cpp
index 9cf20feb73..3c293ea969 100644
--- a/fxjs/cjs_icon.cpp
+++ b/fxjs/cjs_icon.cpp
@@ -30,7 +30,7 @@ CJS_Icon::CJS_Icon(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
CJS_Icon::~CJS_Icon() = default;
CJS_Return CJS_Icon::get_name(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewString(m_swIconName.c_str()));
+ return CJS_Return(pRuntime->NewString(m_swIconName.AsStringView()));
}
CJS_Return CJS_Icon::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 4630445a35..2bc68fa6d3 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -336,13 +336,13 @@ v8::Local<v8::Array> CJS_PublicMethods::AF_MakeArrayFromList(
if (!pTemp) {
pRuntime->PutArrayElement(
StrArray, nIndex,
- pRuntime->NewString(StrTrim(ByteString(p)).c_str()));
+ pRuntime->NewString(StrTrim(ByteString(p)).AsStringView()));
break;
}
pRuntime->PutArrayElement(
StrArray, nIndex,
- pRuntime->NewString(StrTrim(ByteString(p, pTemp - p)).c_str()));
+ pRuntime->NewString(StrTrim(ByteString(p, pTemp - p)).AsStringView()));
nIndex++;
p = ++pTemp;
@@ -1525,11 +1525,11 @@ CJS_Return CJS_PublicMethods::AFMergeChange(
swValue = pEventHandler->Value();
if (pEventHandler->WillCommit())
- return CJS_Return(pRuntime->NewString(swValue.c_str()));
+ return CJS_Return(pRuntime->NewString(swValue.AsStringView()));
WideString merged =
CalcMergedString(pEventHandler, swValue, pEventHandler->Change());
- return CJS_Return(pRuntime->NewString(merged.c_str()));
+ return CJS_Return(pRuntime->NewString(merged.AsStringView()));
}
CJS_Return CJS_PublicMethods::AFParseDateEx(
@@ -1571,7 +1571,7 @@ CJS_Return CJS_PublicMethods::AFMakeNumber(
NormalizeDecimalMarkW(&ws);
v8::Local<v8::Value> val =
- pRuntime->MaybeCoerceToNumber(pRuntime->NewString(ws.c_str()));
+ pRuntime->MaybeCoerceToNumber(pRuntime->NewString(ws.AsStringView()));
if (!val->IsNumber())
return CJS_Return(pRuntime->NewNumber(0));
return CJS_Return(val);
@@ -1734,14 +1734,15 @@ CJS_Return CJS_PublicMethods::AFExtractNums(
sPart += wc;
} else if (sPart.GetLength() > 0) {
pRuntime->PutArrayElement(nums, nIndex,
- pRuntime->NewString(sPart.c_str()));
+ pRuntime->NewString(sPart.AsStringView()));
sPart.clear();
nIndex++;
}
}
- if (sPart.GetLength() > 0)
- pRuntime->PutArrayElement(nums, nIndex, pRuntime->NewString(sPart.c_str()));
-
+ if (sPart.GetLength() > 0) {
+ pRuntime->PutArrayElement(nums, nIndex,
+ pRuntime->NewString(sPart.AsStringView()));
+ }
if (pRuntime->GetArrayLength(nums) > 0)
return CJS_Return(nums);
return CJS_Return(pRuntime->NewUndefined());
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 576a85b999..fec727302d 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -387,7 +387,7 @@ CJS_Return CJS_Util::byteToChar(
return CJS_Return(JSMessage::kValueError);
WideString wStr(static_cast<wchar_t>(arg));
- return CJS_Return(pRuntime->NewString(wStr.c_str()));
+ return CJS_Return(pRuntime->NewString(wStr.AsStringView()));
}
// Ensure that sFormat contains at most one well-understood printf formatting