--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -4770,17 +4770,17 @@ nsDocShell::LoadErrorPage(nsIURI* aURI,
mLSHE->AbandonBFCacheEntry();
}
nsAutoCString url;
if (aURI) {
nsresult rv = aURI->GetSpec(url);
NS_ENSURE_SUCCESS(rv, rv);
} else if (aURL) {
- CopyUTF16toUTF8(aURL, url);
+ CopyUTF16toUTF8(MakeStringSpan(aURL), url);
} else {
return NS_ERROR_INVALID_POINTER;
}
// Create a URL to pass all the error information through to the page.
#undef SAFE_ESCAPE
#define SAFE_ESCAPE(output, input, params) \
--- a/dom/base/DOMException.cpp
+++ b/dom/base/DOMException.cpp
@@ -234,17 +234,17 @@ Exception::GetName(nsAString& aName)
CopyUTF8toUTF16(mName, aName);
} else {
aName.Truncate();
const char* name = nullptr;
nsXPCException::NameAndFormatForNSResult(mResult, &name, nullptr);
if (name) {
- CopyUTF8toUTF16(name, aName);
+ CopyUTF8toUTF16(mozilla::MakeStringSpan(name), aName);
}
}
}
void
Exception::GetFilename(JSContext* aCx, nsAString& aFilename)
{
if (mLocation) {
--- a/dom/base/nsTextFragment.cpp
+++ b/dom/base/nsTextFragment.cpp
@@ -11,17 +11,16 @@
*/
#include "nsTextFragment.h"
#include "nsCRT.h"
#include "nsReadableUtils.h"
#include "nsMemory.h"
#include "nsBidiUtils.h"
#include "nsUnicharUtils.h"
-#include "nsUTF8Utils.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/SSE.h"
#include "nsTextFragmentImpl.h"
#include <algorithm>
#define TEXTFRAG_WHITE_AFTER_NEWLINE 50
#define TEXTFRAG_MAX_NEWLINES 7
@@ -314,18 +313,18 @@ nsTextFragment::SetTo(const char16_t* aB
} else {
// Use 1 byte storage because we can
char* buff = static_cast<char*>(malloc(aLength));
if (!buff) {
return false;
}
// Copy data
- LossyConvertEncoding16to8 converter(buff);
- copy_string(aBuffer, aBuffer+aLength, converter);
+ LossyConvertUTF16toLatin1(MakeSpan(aBuffer, aLength),
+ MakeSpan(buff, aLength));
m1b = buff;
mState.mIs2b = false;
}
// Setup our fields
mState.mInHeap = true;
mState.mLength = aLength;
@@ -346,19 +345,17 @@ nsTextFragment::CopyTo(char16_t *aDest,
aCount = mState.mLength - aOffset;
}
if (aCount != 0) {
if (mState.mIs2b) {
memcpy(aDest, Get2b() + aOffset, sizeof(char16_t) * aCount);
} else {
const char *cp = m1b + aOffset;
- const char *end = cp + aCount;
- LossyConvertEncoding8to16 converter(aDest);
- copy_string(cp, end, converter);
+ ConvertLatin1toUTF16(MakeSpan(cp, aCount), MakeSpan(aDest, aCount));
}
}
}
bool
nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength,
bool aUpdateBidi, bool aForce2b)
{
@@ -435,18 +432,18 @@ nsTextFragment::Append(const char16_t* a
// all to 2-byte
nsStringBuffer* buff = nsStringBuffer::Alloc(size).take();
if (!buff) {
return false;
}
// Copy data into buff
char16_t* data = static_cast<char16_t*>(buff->Data());
- LossyConvertEncoding8to16 converter(data);
- copy_string(m1b, m1b+mState.mLength, converter);
+ ConvertLatin1toUTF16(MakeSpan(m1b, mState.mLength),
+ MakeSpan(data, mState.mLength));
memcpy(data + mState.mLength, aBuffer, aLength * sizeof(char16_t));
mState.mLength += aLength;
mState.mIs2b = true;
if (mState.mInHeap) {
free(const_cast<char*>(m1b));
}
@@ -478,18 +475,18 @@ nsTextFragment::Append(const char16_t* a
return false;
}
memcpy(buff, m1b, mState.mLength);
mState.mInHeap = true;
}
// Copy aBuffer into buff.
- LossyConvertEncoding16to8 converter(buff + mState.mLength);
- copy_string(aBuffer, aBuffer + aLength, converter);
+ LossyConvertUTF16toLatin1(MakeSpan(aBuffer, aLength),
+ MakeSpan(buff + mState.mLength, aLength));
m1b = buff;
mState.mLength += aLength;
return true;
}
/* virtual */ size_t
--- a/dom/base/nsXMLContentSerializer.cpp
+++ b/dom/base/nsXMLContentSerializer.cpp
@@ -587,19 +587,17 @@ nsXMLContentSerializer::ConfirmPrefix(ns
// to create a namespace decl for the final prefix
return true;
}
void
nsXMLContentSerializer::GenerateNewPrefix(nsAString& aPrefix)
{
aPrefix.Assign('a');
- char buf[128];
- SprintfLiteral(buf, "%d", mPrefixIndex++);
- AppendASCIItoUTF16(buf, aPrefix);
+ aPrefix.AppendInt(mPrefixIndex++);
}
bool
nsXMLContentSerializer::SerializeAttr(const nsAString& aPrefix,
const nsAString& aName,
const nsAString& aValue,
nsAString& aStr,
bool aDoEscapeEntities)
@@ -1246,17 +1244,20 @@ nsXMLContentSerializer::AppendAndTransla
if ((val <= kGTVal) && entityTable[val]) {
entityText = kEntityStrings[entityTable[val]];
break;
}
}
NS_ENSURE_TRUE(aOutputStr.Append(fragmentStart, advanceLength, mozilla::fallible), false);
if (entityText) {
- NS_ENSURE_TRUE(AppendASCIItoUTF16(entityText, aOutputStr, mozilla::fallible), false);
+ NS_ENSURE_TRUE(AppendASCIItoUTF16(mozilla::MakeStringSpan(entityText),
+ aOutputStr,
+ mozilla::fallible),
+ false);
advanceLength++;
}
}
return true;
}
bool
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -1137,17 +1137,17 @@ Event::GetWidgetEventType(WidgetEvent* a
if (!aEvent->mSpecifiedEventTypeString.IsEmpty()) {
aType = aEvent->mSpecifiedEventTypeString;
return;
}
const char* name = GetEventName(aEvent->mMessage);
if (name) {
- CopyASCIItoUTF16(name, aType);
+ CopyASCIItoUTF16(mozilla::MakeStringSpan(name), aType);
return;
} else if (aEvent->mMessage == eUnidentifiedEvent &&
aEvent->mSpecifiedEventType) {
// Remove "on"
aType = Substring(nsDependentAtomString(aEvent->mSpecifiedEventType), 2);
aEvent->mSpecifiedEventTypeString = aType;
return;
}
--- a/dom/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/offline/nsDOMOfflineResourceList.cpp
@@ -311,17 +311,17 @@ nsDOMOfflineResourceList::IndexedGetter(
}
if (aIndex >= mCachedKeysCount) {
aFound = false;
return;
}
aFound = true;
- CopyUTF8toUTF16(mCachedKeys[aIndex], aURI);
+ CopyUTF8toUTF16(mozilla::MakeStringSpan(mCachedKeys[aIndex]), aURI);
}
void
nsDOMOfflineResourceList::MozAdd(const nsAString& aURI, ErrorResult& aRv)
{
if (IS_CHILD_PROCESS()) {
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return;
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -605,25 +605,25 @@ static void
ThrowJSExceptionASCII(JSContext *cx, const char *message)
{
const char *ex = PeekException();
if (ex) {
nsAutoString ucex;
if (message) {
- AppendASCIItoUTF16(message, ucex);
-
- AppendASCIItoUTF16(" [plugin exception: ", ucex);
+ AppendASCIItoUTF16(mozilla::MakeStringSpan(message), ucex);
+
+ ucex.AppendLiteral(" [plugin exception: ");
}
- AppendUTF8toUTF16(ex, ucex);
+ AppendUTF8toUTF16(mozilla::MakeStringSpan(ex), ucex);
if (message) {
- AppendASCIItoUTF16("].", ucex);
+ ucex.AppendLiteral("].");
}
JSString *str = ::JS_NewUCStringCopyN(cx, ucex.get(), ucex.Length());
if (str) {
JS::Rooted<JS::Value> exn(cx, JS::StringValue(str));
::JS_SetPendingException(cx, exn);
}
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -850,17 +850,17 @@ nsNPAPIPluginInstance::GetFormValue(nsAS
{
aValue.Truncate();
char *value = nullptr;
nsresult rv = GetValueFromPlugin(NPPVformValue, &value);
if (NS_FAILED(rv) || !value)
return NS_ERROR_FAILURE;
- CopyUTF8toUTF16(value, aValue);
+ CopyUTF8toUTF16(MakeStringSpan(value), aValue);
// NPPVformValue allocates with NPN_MemAlloc(), which uses
// nsMemory.
free(value);
return NS_OK;
}
--- a/dom/presentation/PresentationRequest.cpp
+++ b/dom/presentation/PresentationRequest.cpp
@@ -211,17 +211,17 @@ PresentationRequest::StartWithDevice(con
return promise.forget();
}
nsID uuid;
uuidgen->GenerateUUIDInPlace(&uuid);
char buffer[NSID_LENGTH];
uuid.ToProvidedString(buffer);
nsAutoString id;
- CopyASCIItoUTF16(buffer, id);
+ CopyASCIItoUTF16(MakeSpan(buffer, NSID_LENGTH - 1), id);
nsCOMPtr<nsIPresentationService> service =
do_GetService(PRESENTATION_SERVICE_CONTRACTID);
if(NS_WARN_IF(!service)) {
promise->MaybeReject(NS_ERROR_DOM_OPERATION_ERR);
return promise.forget();
}
--- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp
+++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp
@@ -1529,17 +1529,17 @@ nsWebBrowserPersist::GetExtensionForCont
nsresult rv;
if (!mMIMEService)
{
mMIMEService = do_GetService(NS_MIMESERVICE_CONTRACTID, &rv);
NS_ENSURE_TRUE(mMIMEService, NS_ERROR_FAILURE);
}
nsAutoCString contentType;
- LossyCopyUTF16toASCII(aContentType, contentType);
+ LossyCopyUTF16toASCII(MakeStringSpan(aContentType), contentType);
nsAutoCString ext;
rv = mMIMEService->GetPrimaryExtension(contentType, EmptyCString(), ext);
if (NS_SUCCEEDED(rv))
{
*aExt = UTF8ToNewUnicode(ext);
NS_ENSURE_TRUE(*aExt, NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
}
--- a/dom/xslt/xslt/txEXSLTFunctions.cpp
+++ b/dom/xslt/xslt/txEXSLTFunctions.cpp
@@ -307,18 +307,19 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
nsresult rv = mParams[0]->evaluate(aContext,
getter_AddRefs(exprResult));
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<StringResult> strRes;
rv = aContext->recycler()->getStringResult(getter_AddRefs(strRes));
NS_ENSURE_SUCCESS(rv, rv);
- AppendASCIItoUTF16(sTypes[exprResult->getResultType()],
- strRes->mValue);
+ AppendASCIItoUTF16(
+ MakeStringSpan(sTypes[exprResult->getResultType()]),
+ strRes->mValue);
NS_ADDREF(*aResult = strRes);
return NS_OK;
}
case txEXSLTType::DIFFERENCE:
case txEXSLTType::INTERSECTION:
{
--- a/dom/xslt/xslt/txXSLTNumberCounters.cpp
+++ b/dom/xslt/xslt/txXSLTNumberCounters.cpp
@@ -199,16 +199,21 @@ void txRomanCounter::appendNumber(int32_
aNumber -= 1000;
}
int32_t posValue;
// Hundreds
posValue = aNumber / 100;
aNumber %= 100;
- AppendASCIItoUTF16(kTxRomanNumbers[posValue + mTableOffset], aDest);
+ AppendASCIItoUTF16(
+ mozilla::MakeStringSpan(kTxRomanNumbers[posValue + mTableOffset]), aDest);
// Tens
posValue = aNumber / 10;
aNumber %= 10;
- AppendASCIItoUTF16(kTxRomanNumbers[10 + posValue + mTableOffset], aDest);
+ AppendASCIItoUTF16(
+ mozilla::MakeStringSpan(kTxRomanNumbers[10 + posValue + mTableOffset]),
+ aDest);
// Ones
- AppendASCIItoUTF16(kTxRomanNumbers[20 + aNumber + mTableOffset], aDest);
+ AppendASCIItoUTF16(
+ mozilla::MakeStringSpan(kTxRomanNumbers[20 + aNumber + mTableOffset]),
+ aDest);
}
--- a/editor/libeditor/CSSEditUtils.cpp
+++ b/editor/libeditor/CSSEditUtils.cpp
@@ -60,17 +60,17 @@ void ProcessBValue(const nsAString* aInp
static
void ProcessDefaultValue(const nsAString* aInputString,
nsAString& aOutputString,
const char* aDefaultValueString,
const char* aPrependString,
const char* aAppendString)
{
- CopyASCIItoUTF16(aDefaultValueString, aOutputString);
+ CopyASCIItoUTF16(MakeStringSpan(aDefaultValueString), aOutputString);
}
static
void ProcessSameValue(const nsAString* aInputString,
nsAString & aOutputString,
const char* aDefaultValueString,
const char* aPrependString,
const char* aAppendString)
@@ -87,21 +87,21 @@ void ProcessExtendedValue(const nsAStrin
nsAString& aOutputString,
const char* aDefaultValueString,
const char* aPrependString,
const char* aAppendString)
{
aOutputString.Truncate();
if (aInputString) {
if (aPrependString) {
- AppendASCIItoUTF16(aPrependString, aOutputString);
+ AppendASCIItoUTF16(MakeStringSpan(aPrependString), aOutputString);
}
aOutputString.Append(*aInputString);
if (aAppendString) {
- AppendASCIItoUTF16(aAppendString, aOutputString);
+ AppendASCIItoUTF16(MakeStringSpan(aAppendString), aOutputString);
}
}
}
static
void ProcessLengthValue(const nsAString* aInputString,
nsAString& aOutputString,
const char* aDefaultValueString,
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -423,20 +423,20 @@ FT2FontEntry::CreateFontEntry(FT_Face aF
// and then create our FT2FontEntry
static FT2FontEntry*
CreateNamedFontEntry(FT_Face aFace, const char* aFilename, uint8_t aIndex)
{
if (!aFace->family_name) {
return nullptr;
}
nsAutoString fontName;
- AppendUTF8toUTF16(aFace->family_name, fontName);
+ AppendUTF8toUTF16(mozilla::MakeStringSpan(aFace->family_name), fontName);
if (aFace->style_name && strcmp("Regular", aFace->style_name)) {
fontName.Append(' ');
- AppendUTF8toUTF16(aFace->style_name, fontName);
+ AppendUTF8toUTF16(mozilla::MakeStringSpan(aFace->style_name), fontName);
}
return FT2FontEntry::CreateFontEntry(aFace, aFilename, aIndex, fontName);
}
FT2FontEntry*
gfxFT2Font::GetFontEntry()
{
return static_cast<FT2FontEntry*> (mFontEntry.get());
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -125,41 +125,41 @@ FindCanonicalNameIndex(FcPattern* aFont,
static void
GetFaceNames(FcPattern* aFont, const nsAString& aFamilyName,
nsAString& aPostscriptName, nsAString& aFullname)
{
// get the Postscript name
FcChar8* psname;
if (FcPatternGetString(aFont, FC_POSTSCRIPT_NAME, 0, &psname) == FcResultMatch) {
- AppendUTF8toUTF16(ToCharPtr(psname), aPostscriptName);
+ AppendUTF8toUTF16(MakeStringSpan(ToCharPtr(psname)), aPostscriptName);
}
// get the canonical fullname (i.e. en name or first name)
uint32_t en = FindCanonicalNameIndex(aFont, FC_FULLNAMELANG);
FcChar8* fullname;
if (FcPatternGetString(aFont, FC_FULLNAME, en, &fullname) == FcResultMatch) {
- AppendUTF8toUTF16(ToCharPtr(fullname), aFullname);
+ AppendUTF8toUTF16(MakeStringSpan(ToCharPtr(fullname)), aFullname);
}
// if have fullname, done
if (!aFullname.IsEmpty()) {
return;
}
// otherwise, set the fullname to family + style name [en] and use that
aFullname.Append(aFamilyName);
// figure out the en style name
en = FindCanonicalNameIndex(aFont, FC_STYLELANG);
nsAutoString style;
FcChar8* stylename = nullptr;
FcPatternGetString(aFont, FC_STYLE, en, &stylename);
if (stylename) {
- AppendUTF8toUTF16(ToCharPtr(stylename), style);
+ AppendUTF8toUTF16(MakeStringSpan(ToCharPtr(stylename)), style);
}
if (!style.IsEmpty() && !style.EqualsLiteral("Regular")) {
aFullname.Append(' ');
aFullname.Append(style);
}
}
@@ -1573,17 +1573,17 @@ gfxFcPlatformFontList::AddPatternToFontL
}
// same as the last one? no need to add a new family, skip
if (FcStrCmp(canonical, aLastFamilyName) != 0) {
aLastFamilyName = canonical;
// add new family if one doesn't already exist
aFamilyName.Truncate();
- AppendUTF8toUTF16(ToCharPtr(canonical), aFamilyName);
+ AppendUTF8toUTF16(MakeStringSpan(ToCharPtr(canonical)), aFamilyName);
nsAutoString keyName(aFamilyName);
ToLowerCase(keyName);
aFontFamily = static_cast<gfxFontconfigFontFamily*>
(mFontFamilies.GetWeak(keyName));
if (!aFontFamily) {
aFontFamily = new gfxFontconfigFontFamily(aFamilyName);
mFontFamilies.Put(keyName, aFontFamily);
@@ -1805,17 +1805,17 @@ GetSystemFontList(nsTArray<nsString>& aL
if (FcPatternGetString(fs->fonts[i], FC_FAMILY, 0,
(FcChar8 **) &family) != FcResultMatch)
{
continue;
}
// Remove duplicates...
nsAutoString strFamily;
- AppendUTF8toUTF16(family, strFamily);
+ AppendUTF8toUTF16(MakeStringSpan(family), strFamily);
if (aListOfFonts.Contains(strFamily)) {
continue;
}
aListOfFonts.AppendElement(strFamily);
}
aListOfFonts.Sort();
--- a/intl/lwbrk/nsPangoBreaker.cpp
+++ b/intl/lwbrk/nsPangoBreaker.cpp
@@ -37,21 +37,23 @@ NS_GetComplexLineBreaks(const char16_t*
while (p < end)
{
aBreakBefore[u16Offset] = attr->is_line_break;
if (NS_IS_LOW_SURROGATE(aText[u16Offset]))
aBreakBefore[++u16Offset] = false; // Skip high surrogate
++u16Offset;
- bool err;
- uint32_t ch = UTF8CharEnumerator::NextChar(&p, end, &err);
+ // We're iterating over text obtained from NS_ConvertUTF16toUTF8,
+ // so we know we have valid UTF-8 and don't need to check for
+ // errors.
+ uint32_t ch = UTF8CharEnumerator::NextChar(&p, end);
++attr;
- if (ch == 0 || err) {
+ if (!ch) {
// pango_break (pango 1.16.2) only analyses text before the
// first NUL (but sets one extra attr). Workaround loop to call
// pango_break again to analyse after the NUL is done somewhere else
// (gfx/thebes/gfxFontconfigFonts.cpp: SetupClusterBoundaries()).
// So, we do the same here for pango_get_log_attrs.
break;
}
}
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -472,17 +472,20 @@ GeckoChildProcessHost::GetChildLogName(c
// the path against the sanboxing rules as passed to fopen (left relative).
char absPath[MAX_PATH + 2];
if (_fullpath(absPath, origLogName, sizeof(absPath))) {
#ifdef MOZ_SANDBOX
// We need to make sure the child log name doesn't contain any junction
// points or symlinks or the sandbox will reject rules to allow writing.
std::wstring resolvedPath(NS_ConvertUTF8toUTF16(absPath).get());
if (widget::WinUtils::ResolveJunctionPointsAndSymLinks(resolvedPath)) {
- AppendUTF16toUTF8(resolvedPath.c_str(), buffer);
+ AppendUTF16toUTF8(
+ MakeSpan(reinterpret_cast<const char16_t*>(resolvedPath.data()),
+ resolvedPath.size()),
+ buffer);
} else
#endif
{
buffer.Append(absPath);
}
} else
#endif
{
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -2099,17 +2099,17 @@ nsXPCComponents_Utils::ReportError(Handl
if (!scripterr) {
scripterr = new nsScriptError();
}
if (err) {
// It's a proper JS Error
nsAutoString fileUni;
- CopyUTF8toUTF16(err->filename, fileUni);
+ CopyUTF8toUTF16(mozilla::MakeStringSpan(err->filename), fileUni);
uint32_t column = err->tokenOffset();
const char16_t* linebuf = err->linebuf();
nsresult rv = scripterr->InitWithWindowID(
err->message() ? NS_ConvertUTF8toUTF16(err->message().c_str())
: EmptyString(),
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -188,17 +188,17 @@ nsXPConnect::IsISupportsDescendant(const
}
void
xpc::ErrorBase::Init(JSErrorBase* aReport)
{
if (!aReport->filename)
mFileName.SetIsVoid(true);
else
- CopyASCIItoUTF16(aReport->filename, mFileName);
+ CopyUTF8toUTF16(mozilla::MakeStringSpan(aReport->filename), mFileName);
mLineNumber = aReport->lineno;
mColumn = aReport->column;
}
void
xpc::ErrorNote::Init(JSErrorNotes::Note* aNote)
{
@@ -213,17 +213,17 @@ xpc::ErrorReport::Init(JSErrorReport* aR
{
xpc::ErrorBase::Init(aReport);
mCategory = aIsChrome ? NS_LITERAL_CSTRING("chrome javascript")
: NS_LITERAL_CSTRING("content javascript");
mWindowID = aWindowID;
ErrorReportToMessageString(aReport, mErrorMsg);
if (mErrorMsg.IsEmpty() && aToStringResult) {
- AppendUTF8toUTF16(aToStringResult, mErrorMsg);
+ AppendUTF8toUTF16(mozilla::MakeStringSpan(aToStringResult), mErrorMsg);
}
mSourceLine.Assign(aReport->linebuf(), aReport->linebufLength());
const JSErrorFormatString* efs = js::GetErrorMessage(nullptr, aReport->errorNumber);
if (efs == nullptr) {
mErrorMsgName.AssignASCII("");
} else {
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -2455,17 +2455,17 @@ HttpBaseChannel::GetResponseVersion(uint
}
void
HttpBaseChannel::NotifySetCookie(char const *aCookie)
{
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (obs) {
nsAutoString cookie;
- CopyASCIItoUTF16(aCookie, cookie);
+ CopyASCIItoUTF16(mozilla::MakeStringSpan(aCookie), cookie);
obs->NotifyObservers(static_cast<nsIChannel*>(this),
"http-on-response-set-cookie",
cookie.get());
}
}
NS_IMETHODIMP
HttpBaseChannel::SetCookie(const char *aCookieHeader)
--- a/netwerk/protocol/http/nsHttpBasicAuth.cpp
+++ b/netwerk/protocol/http/nsHttpBasicAuth.cpp
@@ -72,21 +72,19 @@ nsHttpBasicAuth::GenerateCredentials(nsI
*aFlags = 0;
// we only know how to deal with Basic auth for http.
bool isBasicAuth = !PL_strncasecmp(challenge, "basic", 5);
NS_ENSURE_TRUE(isBasicAuth, NS_ERROR_UNEXPECTED);
// we work with UTF-8 around here
nsAutoCString userpass;
- CopyUTF16toUTF8(user, userpass);
+ CopyUTF16toUTF8(mozilla::MakeStringSpan(user), userpass);
userpass.Append(':'); // always send a ':' (see bug 129565)
- if (password) {
- AppendUTF16toUTF8(password, userpass);
- }
+ AppendUTF16toUTF8(mozilla::MakeStringSpan(password), userpass);
nsAutoCString authString;
nsresult rv = Base64Encode(userpass, authString);
NS_ENSURE_SUCCESS(rv, rv);
authString.InsertLiteral("Basic ", 0);
*creds = ToNewCString(authString);
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -6254,25 +6254,25 @@ nsHttpChannel::BeginConnect()
rv = mRequestHead.SetHeader(nsHttp::Alternate_Service_Used, altUsedLine);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (consoleService) {
nsAutoString message(NS_LITERAL_STRING("Alternate Service Mapping found: "));
- AppendASCIItoUTF16(scheme.get(), message);
+ AppendASCIItoUTF16(scheme, message);
message.AppendLiteral(u"://");
- AppendASCIItoUTF16(host.get(), message);
+ AppendASCIItoUTF16(host, message);
message.AppendLiteral(u":");
message.AppendInt(port);
message.AppendLiteral(u" to ");
- AppendASCIItoUTF16(scheme.get(), message);
+ AppendASCIItoUTF16(scheme, message);
message.AppendLiteral(u"://");
- AppendASCIItoUTF16(mapping->AlternateHost().get(), message);
+ AppendASCIItoUTF16(mapping->AlternateHost(), message);
message.AppendLiteral(u":");
message.AppendInt(mapping->AlternatePort());
consoleService->LogStringMessage(message.get());
}
LOG(("nsHttpChannel %p Using connection info from altsvc mapping", this));
mapping->GetConnectionInfo(getter_AddRefs(mConnectionInfo), proxyInfo, originAttributes);
Telemetry::Accumulate(Telemetry::HTTP_TRANSACTION_USE_ALTSVC, true);
--- a/parser/html/nsHtml5String.cpp
+++ b/parser/html/nsHtml5String.cpp
@@ -165,18 +165,17 @@ nsHtml5String::FromLiteral(const char* a
// nsAttrValue::GetStringBuffer, so that it doesn't need to reallocate and
// copy.
RefPtr<nsStringBuffer> buffer(
nsStringBuffer::Alloc((length + 1) * sizeof(char16_t)));
if (!buffer) {
MOZ_CRASH("Out of memory.");
}
char16_t* data = reinterpret_cast<char16_t*>(buffer->Data());
- LossyConvertEncoding8to16 converter(data);
- converter.write(aLiteral, length);
+ ConvertLatin1toUTF16(MakeSpan(aLiteral, length), MakeSpan(data, length));
data[length] = 0;
return nsHtml5String(reinterpret_cast<uintptr_t>(buffer.forget().take()) |
eStringBuffer);
}
// static
nsHtml5String
nsHtml5String::FromString(const nsAString& aString)
--- a/parser/htmlparser/nsExpatDriver.cpp
+++ b/parser/htmlparser/nsExpatDriver.cpp
@@ -26,16 +26,17 @@
#include "nsUnicharInputStream.h"
#include "nsContentUtils.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/Logging.h"
using mozilla::fallible;
using mozilla::LogLevel;
+using mozilla::MakeStringSpan;
#define kExpatSeparatorChar 0xFFFF
static const char16_t kUTF16[] = { 'U', 'T', 'F', '-', '1', '6', '\0' };
static mozilla::LazyLogModule gExpatDriverLog("expatdriver");
/***************************** EXPAT CALL BACKS ******************************/
@@ -573,21 +574,21 @@ nsExpatDriver::HandleExternalEntityRef(c
// Load the external entity into a buffer.
nsCOMPtr<nsIInputStream> in;
nsAutoString absURL;
nsresult rv = OpenInputStreamFromExternalDTD(publicId, systemId, base,
getter_AddRefs(in), absURL);
if (NS_FAILED(rv)) {
#ifdef DEBUG
nsCString message("Failed to open external DTD: publicId \"");
- AppendUTF16toUTF8(publicId, message);
+ AppendUTF16toUTF8(MakeStringSpan(publicId), message);
message += "\" systemId \"";
- AppendUTF16toUTF8(systemId, message);
+ AppendUTF16toUTF8(MakeStringSpan(systemId), message);
message += "\" base \"";
- AppendUTF16toUTF8(base, message);
+ AppendUTF16toUTF8(MakeStringSpan(base), message);
message += "\" URL \"";
AppendUTF16toUTF8(absURL, message);
message += "\"";
NS_WARNING(message.get());
#endif
return 1;
}
--- a/security/manager/ssl/nsNSSCertHelper.cpp
+++ b/security/manager/ssl/nsNSSCertHelper.cpp
@@ -904,17 +904,18 @@ AppendBMPtoUTF16(const UniquePLArenaPool
be sufficient to just swap bytes, or do nothing */
unsigned int utf8ValLen = len * 3 + 1;
unsigned char* utf8Val =
(unsigned char*)PORT_ArenaZAlloc(arena.get(), utf8ValLen);
if (!PORT_UCS2_UTF8Conversion(
false, data, len, utf8Val, utf8ValLen, &utf8ValLen)) {
return NS_ERROR_FAILURE;
}
- AppendUTF8toUTF16((char*)utf8Val, text);
+ AppendUTF8toUTF16(MakeSpan(reinterpret_cast<char*>(utf8Val), utf8ValLen),
+ text);
return NS_OK;
}
static nsresult
ProcessGeneralName(const UniquePLArenaPool& arena, CERTGeneralName* current,
nsAString& text)
{
NS_ENSURE_ARG_POINTER(current);
--- a/security/manager/ssl/nsNSSCertificate.cpp
+++ b/security/manager/ssl/nsNSSCertificate.cpp
@@ -362,17 +362,17 @@ nsNSSCertificate::GetDisplayName(nsAStri
return NS_OK;
}
NS_IMETHODIMP
nsNSSCertificate::GetEmailAddress(nsAString& aEmailAddress)
{
if (mCert->emailAddr) {
- LossyUTF8ToUTF16(mCert->emailAddr, strlen(mCert->emailAddr), aEmailAddress);
+ CopyUTF8toUTF16(MakeStringSpan(mCert->emailAddr), aEmailAddress);
} else {
GetPIPNSSBundleString("CertNoEmailAddress", aEmailAddress);
}
return NS_OK;
}
NS_IMETHODIMP
nsNSSCertificate::GetEmailAddresses(uint32_t* aLength, char16_t*** aAddresses)
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -2119,25 +2119,25 @@ fn static_assert() {
};
let mut refptr = unsafe {
UniqueRefPtr::from_addrefed(
Gecko_NewGridTemplateAreasValue(v.0.areas.len() as u32, v.0.strings.len() as u32, v.0.width))
};
for (servo, gecko) in v.0.areas.into_iter().zip(refptr.mNamedAreas.iter_mut()) {
- gecko.mName.assign_utf8(&*servo.name);
+ gecko.mName.assign_str(&*servo.name);
gecko.mColumnStart = servo.columns.start;
gecko.mColumnEnd = servo.columns.end;
gecko.mRowStart = servo.rows.start;
gecko.mRowEnd = servo.rows.end;
}
for (servo, gecko) in v.0.strings.into_iter().zip(refptr.mTemplates.iter_mut()) {
- gecko.assign_utf8(&*servo);
+ gecko.assign_str(&*servo);
}
self.gecko.mGridTemplateAreas.set_move(refptr.get())
}
pub fn copy_grid_template_areas_from(&mut self, other: &Self) {
unsafe { self.gecko.mGridTemplateAreas.set(&other.gecko.mGridTemplateAreas) }
}
@@ -4181,18 +4181,18 @@ fn static_assert() {
use gecko_bindings::bindings::Gecko_NewStyleQuoteValues;
use gecko_bindings::sugar::refptr::UniqueRefPtr;
let mut refptr = unsafe {
UniqueRefPtr::from_addrefed(Gecko_NewStyleQuoteValues(other.0.len() as u32))
};
for (servo, gecko) in other.0.into_iter().zip(refptr.mQuotePairs.iter_mut()) {
- gecko.first.assign_utf8(&servo.0);
- gecko.second.assign_utf8(&servo.1);
+ gecko.first.assign_str(&servo.0);
+ gecko.second.assign_str(&servo.1);
}
self.gecko.mQuotes.set_move(refptr.get())
}
pub fn copy_quotes_from(&mut self, other: &Self) {
unsafe { self.gecko.mQuotes.set(&other.gecko.mQuotes); }
}
@@ -4720,17 +4720,17 @@ fn static_assert() {
};
(shape | fill, keyword.shape.char(keyword.fill))
},
TextEmphasisStyle::String(ref s) => {
(structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING, &**s)
},
};
- self.gecko.mTextEmphasisStyleString.assign_utf8(s);
+ self.gecko.mTextEmphasisStyleString.assign_str(s);
self.gecko.mTextEmphasisStyle = te as u8;
}
pub fn copy_text_emphasis_style_from(&mut self, other: &Self) {
self.clear_text_emphasis_style_if_string();
if other.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING as u8 {
self.gecko.mTextEmphasisStyleString
.assign(&*other.gecko.mTextEmphasisStyleString)
@@ -4821,17 +4821,17 @@ fn static_assert() {
use gecko_bindings::structs::nsStyleTextOverflowSide;
use values::specified::text::TextOverflowSide;
fn set(side: &mut nsStyleTextOverflowSide, value: &TextOverflowSide) {
let ty = match *value {
TextOverflowSide::Clip => structs::NS_STYLE_TEXT_OVERFLOW_CLIP,
TextOverflowSide::Ellipsis => structs::NS_STYLE_TEXT_OVERFLOW_ELLIPSIS,
TextOverflowSide::String(ref s) => {
- side.mString.assign_utf8(s);
+ side.mString.assign_str(s);
structs::NS_STYLE_TEXT_OVERFLOW_STRING
}
};
side.mType = ty as u8;
}
self.clear_overflow_sides_if_string();
self.gecko.mTextOverflow.mLogicalDirections = v.sides_are_logical;
@@ -5453,17 +5453,17 @@ clip-path
) {
debug_assert!(content_type == StyleContentType::Counter ||
content_type == StyleContentType::Counters);
let counter_func = unsafe {
bindings::Gecko_SetCounterFunction(data, content_type).as_mut().unwrap()
};
counter_func.mIdent.assign(name.0.as_slice());
if content_type == StyleContentType::Counters {
- counter_func.mSeparator.assign_utf8(sep);
+ counter_func.mSeparator.assign_str(sep);
}
style.to_gecko_value(&mut counter_func.mCounterStyle, device);
}
match v {
Content::None |
Content::Normal => {
// Ensure destructors run, otherwise we could leak.
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -680,17 +680,17 @@ nsWindowWatcher::OpenWindowInternal(mozI
if (NS_FAILED(rv)) {
return rv;
}
uriToLoad->SchemeIs("chrome", &uriToLoadIsChrome);
}
bool nameSpecified = false;
if (aName) {
- CopyUTF8toUTF16(aName, name);
+ CopyUTF8toUTF16(MakeStringSpan(aName), name);
nameSpecified = true;
} else {
name.SetIsVoid(true);
}
if (aFeatures) {
features.Assign(aFeatures);
features.StripWhitespace();
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2170,17 +2170,17 @@ ShowProfileManager(nsIToolkitProfileServ
NS_ENSURE_SUCCESS(rv, rv);
rv = lock->GetLocalDirectory(getter_AddRefs(profLD));
NS_ENSURE_SUCCESS(rv, rv);
rv = ioParamBlock->GetString(0, &profileNamePtr);
NS_ENSURE_SUCCESS(rv, rv);
- CopyUTF16toUTF8(profileNamePtr, profileName);
+ CopyUTF16toUTF8(MakeStringSpan(profileNamePtr), profileName);
free(profileNamePtr);
lock->Unlock();
}
}
SaveFileToEnv("XRE_PROFILE_PATH", profD);
SaveFileToEnv("XRE_PROFILE_LOCAL_PATH", profLD);
--- a/toolkit/xre/nsNativeAppSupportWin.cpp
+++ b/toolkit/xre/nsNativeAppSupportWin.cpp
@@ -517,17 +517,19 @@ struct MessageWindow {
NS_IMETHOD SendRequest() {
WCHAR *cmd = ::GetCommandLineW();
WCHAR cwd[MAX_PATH];
_wgetcwd(cwd, MAX_PATH);
// Construct a narrow UTF8 buffer <commandline>\0<workingdir>\0
NS_ConvertUTF16toUTF8 utf8buffer(cmd);
utf8buffer.Append('\0');
- AppendUTF16toUTF8(cwd, utf8buffer);
+ WCHAR* cwdPtr = cwd;
+ AppendUTF16toUTF8(MakeStringSpan(reinterpret_cast<char16_t*>(cwdPtr)),
+ utf8buffer);
utf8buffer.Append('\0');
// We used to set dwData to zero, when we didn't send the working dir.
// Now we're using it as a version number.
COPYDATASTRUCT cds = {
1,
utf8buffer.Length(),
(void*) utf8buffer.get()
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -2786,17 +2786,17 @@ NS_IMETHODIMP nsExternalHelperAppService
nsAutoCString fileExt;
if (!fileName.IsEmpty())
{
int32_t len = fileName.Length();
for (int32_t i = len; i >= 0; i--)
{
if (fileName[i] == char16_t('.'))
{
- CopyUTF16toUTF8(fileName.get() + i + 1, fileExt);
+ CopyUTF16toUTF8(Substring(fileName, i + 1), fileExt);
break;
}
}
}
if (fileExt.IsEmpty())
return NS_ERROR_FAILURE;
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -1873,17 +1873,17 @@ IMContextWrapper::GetCompositionString(G
nsAString& aCompositionString)
{
gchar *preedit_string;
gint cursor_pos;
PangoAttrList *feedback_list;
gtk_im_context_get_preedit_string(aContext, &preedit_string,
&feedback_list, &cursor_pos);
if (preedit_string && *preedit_string) {
- CopyUTF8toUTF16(preedit_string, aCompositionString);
+ CopyUTF8toUTF16(MakeStringSpan(preedit_string), aCompositionString);
} else {
aCompositionString.Truncate();
}
MOZ_LOG(gGtkIMLog, LogLevel::Info,
("0x%p GetCompositionString(aContext=0x%p), "
"aCompositionString=\"%s\"",
this, aContext, preedit_string));
--- a/widget/gtk/nsDeviceContextSpecG.cpp
+++ b/widget/gtk/nsDeviceContextSpecG.cpp
@@ -433,17 +433,17 @@ nsPrinterEnumeratorGTK::InitPrintSetting
nsresult rv = aPrintSettings->GetToFileName(filename);
if (NS_FAILED(rv) || filename.IsEmpty()) {
const char* path = PR_GetEnv("PWD");
if (!path) {
path = PR_GetEnv("HOME");
}
if (path) {
- CopyUTF8toUTF16(path, filename);
+ CopyUTF8toUTF16(MakeStringSpan(path), filename);
filename.AppendLiteral("/mozilla.pdf");
} else {
filename.AssignLiteral("mozilla.pdf");
}
DO_PR_DEBUG_LOG(("Setting default filename to '%s'\n",
NS_ConvertUTF16toUTF8(filename).get()));
aPrintSettings->SetToFileName(filename);
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -3288,21 +3288,18 @@ case _value: eventName.AssignLiteral(_na
_ASSIGN_eventName(eReadyStateChange,"eReadyStateChange");
_ASSIGN_eventName(eXULBroadcast, "eXULBroadcast");
_ASSIGN_eventName(eXULCommandUpdate, "eXULCommandUpdate");
#undef _ASSIGN_eventName
default:
{
- char buf[32];
-
- SprintfLiteral(buf,"UNKNOWN: %d",aGuiEvent->mMessage);
-
- CopyASCIItoUTF16(buf, eventName);
+ eventName.AssignLiteral("UNKNOWN: ");
+ eventName.AppendInt(aGuiEvent->mMessage);
}
break;
}
return nsAutoString(eventName);
}
//////////////////////////////////////////////////////////////
//
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -1640,17 +1640,17 @@ CycleCollectedJSRuntime::ErrorIntercepto
// If `exn` isn't an exception object, `ExtractErrorValues` could end up calling
// `toString()`, which could in turn end up throwing an error. While this should
// work, we want to avoid that complex use case.
// Fortunately, we have already checked above that `exn` is an exception object,
// so nothing such should happen.
nsContentUtils::ExtractErrorValues(cx, value, details.mFilename, &details.mLine, &details.mColumn, details.mMessage);
JS::UniqueChars buf = JS::FormatStackDump(cx, nullptr, /* showArgs = */ false, /* showLocals = */ false, /* showThisProps = */ false);
- CopyUTF8toUTF16(buf.get(), details.mStack);
+ CopyUTF8toUTF16(mozilla::MakeStringSpan(buf.get()), details.mStack);
mThrownError.emplace(std::move(details));
}
void
CycleCollectedJSRuntime::ClearRecentDevError()
{
mErrorInterceptor.mThrownError.reset();
--- a/xpcom/ds/nsVariant.cpp
+++ b/xpcom/ds/nsVariant.cpp
@@ -824,17 +824,17 @@ nsDiscriminatedUnion::ConvertToAString(n
return NS_OK;
case nsIDataType::VTYPE_CSTRING:
CopyASCIItoUTF16(*u.mCStringValue, aResult);
return NS_OK;
case nsIDataType::VTYPE_UTF8STRING:
CopyUTF8toUTF16(*u.mUTF8StringValue, aResult);
return NS_OK;
case nsIDataType::VTYPE_CHAR_STR:
- CopyASCIItoUTF16(u.str.mStringValue, aResult);
+ CopyASCIItoUTF16(mozilla::MakeStringSpan(u.str.mStringValue), aResult);
return NS_OK;
case nsIDataType::VTYPE_WCHAR_STR:
aResult.Assign(u.wstr.mWStringValue);
return NS_OK;
case nsIDataType::VTYPE_STRING_SIZE_IS:
CopyASCIItoUTF16(nsDependentCString(u.str.mStringValue,
u.str.mStringLength),
aResult);
@@ -919,17 +919,17 @@ nsDiscriminatedUnion::ConvertToAUTF8Stri
return NS_OK;
case nsIDataType::VTYPE_CHAR_STR:
// XXX Extra copy, can be removed if we're sure CHAR_STR can
// only contain ASCII.
CopyUTF16toUTF8(NS_ConvertASCIItoUTF16(u.str.mStringValue),
aResult);
return NS_OK;
case nsIDataType::VTYPE_WCHAR_STR:
- CopyUTF16toUTF8(u.wstr.mWStringValue, aResult);
+ CopyUTF16toUTF8(mozilla::MakeStringSpan(u.wstr.mWStringValue), aResult);
return NS_OK;
case nsIDataType::VTYPE_STRING_SIZE_IS:
// XXX Extra copy, can be removed if we're sure CHAR_STR can
// only contain ASCII.
CopyUTF16toUTF8(NS_ConvertASCIItoUTF16(
nsDependentCString(u.str.mStringValue,
u.str.mStringLength)), aResult);
return NS_OK;
--- a/xpcom/glue/FileUtils.cpp
+++ b/xpcom/glue/FileUtils.cpp
@@ -167,17 +167,17 @@ mozilla::PathString
mozilla::GetLibraryName(mozilla::pathstr_t aDirectory, const char* aLib)
{
#ifdef XP_WIN
nsAutoString fullName;
if (aDirectory) {
fullName.Assign(aDirectory);
fullName.Append('\\');
}
- AppendUTF8toUTF16(aLib, fullName);
+ AppendUTF8toUTF16(MakeStringSpan(aLib), fullName);
if (!strstr(aLib, ".dll")) {
fullName.AppendLiteral(".dll");
}
return fullName;
#else
char* temp = PR_GetLibraryName(aDirectory, aLib);
if (!temp) {
return EmptyCString();
--- a/xpcom/string/nsString.h
+++ b/xpcom/string/nsString.h
@@ -42,17 +42,17 @@ static_assert(sizeof(nsTLiteralString<ch
/**
* A helper class that converts a UTF-16 string to ASCII in a lossy manner
*/
class NS_LossyConvertUTF16toASCII : public nsAutoCString
{
public:
explicit NS_LossyConvertUTF16toASCII(const char16ptr_t aString)
{
- LossyAppendUTF16toASCII(aString, *this);
+ LossyAppendUTF16toASCII(mozilla::MakeStringSpan(aString), *this);
}
NS_LossyConvertUTF16toASCII(const char16ptr_t aString, uint32_t aLength)
{
LossyAppendUTF16toASCII(Substring(static_cast<const char16_t*>(aString), aLength), *this);
}
explicit NS_LossyConvertUTF16toASCII(const nsAString& aString)
@@ -66,17 +66,17 @@ private:
};
class NS_ConvertASCIItoUTF16 : public nsAutoString
{
public:
explicit NS_ConvertASCIItoUTF16(const char* aCString)
{
- AppendASCIItoUTF16(aCString, *this);
+ AppendASCIItoUTF16(mozilla::MakeStringSpan(aCString), *this);
}
NS_ConvertASCIItoUTF16(const char* aCString, uint32_t aLength)
{
AppendASCIItoUTF16(Substring(aCString, aLength), *this);
}
explicit NS_ConvertASCIItoUTF16(const nsACString& aCString)
@@ -93,17 +93,17 @@ private:
/**
* A helper class that converts a UTF-16 string to UTF-8
*/
class NS_ConvertUTF16toUTF8 : public nsAutoCString
{
public:
explicit NS_ConvertUTF16toUTF8(const char16ptr_t aString)
{
- AppendUTF16toUTF8(aString, *this);
+ AppendUTF16toUTF8(mozilla::MakeStringSpan(aString), *this);
}
NS_ConvertUTF16toUTF8(const char16ptr_t aString, uint32_t aLength)
{
AppendUTF16toUTF8(Substring(static_cast<const char16_t*>(aString), aLength), *this);
}
explicit NS_ConvertUTF16toUTF8(const nsAString& aString)
@@ -117,17 +117,17 @@ private:
};
class NS_ConvertUTF8toUTF16 : public nsAutoString
{
public:
explicit NS_ConvertUTF8toUTF16(const char* aCString)
{
- AppendUTF8toUTF16(aCString, *this);
+ AppendUTF8toUTF16(mozilla::MakeStringSpan(aCString), *this);
}
NS_ConvertUTF8toUTF16(const char* aCString, uint32_t aLength)
{
AppendUTF8toUTF16(Substring(aCString, aLength), *this);
}
explicit NS_ConvertUTF8toUTF16(const nsACString& aCString)
--- a/xpcom/tests/gtest/TestCRT.cpp
+++ b/xpcom/tests/gtest/TestCRT.cpp
@@ -37,18 +37,18 @@ static void Check(const char* s1, const
int clib = PL_strcmp(s1, s2);
int clib_n = PL_strncmp(s1, s2, n);
if (!longerThanN) {
EXPECT_EQ(sign(clib), sign(clib_n));
}
nsAutoString t1,t2;
- CopyASCIItoUTF16(s1, t1);
- CopyASCIItoUTF16(s2, t2);
+ CopyASCIItoUTF16(mozilla::MakeStringSpan(s1), t1);
+ CopyASCIItoUTF16(mozilla::MakeStringSpan(s2), t2);
const char16_t* us1 = t1.get();
const char16_t* us2 = t2.get();
int u2, u2_n;
u2 = nsCRT::strcmp(us1, us2);
EXPECT_EQ(sign(clib), sign(u2));