Patch for bug 209699 (convert some consumers over to CopyUTF8toUTF16 / CopyUTF16toUTF8). r=jshin, sr=jst.

This commit is contained in:
peter%propagandism.org 2003-12-23 16:48:40 +00:00
Родитель a9ca4bdf33
Коммит a42e149448
22 изменённых файлов: 45 добавлений и 51 удалений

Просмотреть файл

@ -166,7 +166,7 @@ getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
nsresult rv = accText->GetText(aStartOffset, aEndOffset, autoStr);
NS_ENSURE_SUCCESS(rv, nsnull);
nsCAutoString cautoStr = NS_ConvertUCS2toUTF8(autoStr);
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
//copy and return, libspi will free it.
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
@ -195,7 +195,7 @@ getTextAfterOffsetCB(AtkText *aText, gint aOffset,
NS_ENSURE_SUCCESS(rv, nsnull);
nsCAutoString cautoStr = NS_ConvertUCS2toUTF8(autoStr);
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
}
@ -222,7 +222,7 @@ getTextAtOffsetCB(AtkText *aText, gint aOffset,
NS_ENSURE_SUCCESS(rv, nsnull);
nsCAutoString cautoStr = NS_ConvertUCS2toUTF8(autoStr);
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
}
@ -268,7 +268,7 @@ getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
NS_ENSURE_SUCCESS(rv, nsnull);
nsCAutoString cautoStr = NS_ConvertUCS2toUTF8(autoStr);
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
}

Просмотреть файл

@ -180,9 +180,7 @@ NS_IMETHODIMP nsDocAccessible::GetURL(nsAString& aURL)
if (pURI)
pURI->GetSpec(theURL);
}
//XXXaaronl Need to use CopyUTF8toUCS2(nsDependentCString(theURL), aURL);
// when it's written
aURL.Assign(NS_ConvertUTF8toUCS2(theURL));
CopyUTF8toUTF16(theURL, aURL);
return NS_OK;
}

Просмотреть файл

@ -395,9 +395,9 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetValue(nsAString& _retval)
PRInt32 level;
mTreeView->GetLevel(mRow, &level);
nsCString str;
nsString str;
str.AppendInt(level);
_retval = NS_ConvertASCIItoUCS2(str);
_retval = str;
return NS_OK;
}

Просмотреть файл

@ -2531,7 +2531,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI, const PRUnichar *aUR
// Get the host
nsCAutoString host;
aURI->GetHost(host);
formatStrs[0].Assign(NS_ConvertUTF8toUCS2(host));
CopyUTF8toUTF16(host, formatStrs[0]);
formatStrCount = 1;
error.Assign(NS_LITERAL_STRING("dnsNotFound"));
}
@ -2558,7 +2558,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI, const PRUnichar *aUR
// Get the host
nsCAutoString host;
aURI->GetHost(host);
formatStrs[0].Assign(NS_ConvertUTF8toUCS2(host));
CopyUTF8toUTF16(host, formatStrs[0]);
formatStrCount = 1;
error.Assign(NS_LITERAL_STRING("netTimeout"));
}

Просмотреть файл

@ -862,10 +862,8 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
if(keywordsEnabled && (-1 == dotLoc)) {
// only send non-qualified hosts to the keyword server
nsAutoString keywordSpec; keywordSpec.AssignWithConversion("keyword:");
keywordSpec.Append(NS_ConvertUTF8toUCS2(host));
NS_NewURI(getter_AddRefs(newURI), keywordSpec, nsnull);
NS_NewURI(getter_AddRefs(newURI),
NS_LITERAL_CSTRING("keyword:") + host, nsnull);
} // end keywordsEnabled
}

Просмотреть файл

@ -377,7 +377,7 @@ NS_IMETHODIMP nsMetaCharsetObserver::GetCharsetFromCompatibilityTag(
!preferred.Equals(NS_LITERAL_CSTRING("UTF-16LE")) &&
!preferred.Equals(NS_LITERAL_CSTRING("UTF-32BE")) &&
!preferred.Equals(NS_LITERAL_CSTRING("UTF-32LE")))
aCharset = NS_ConvertASCIItoUCS2(preferred);
AppendASCIItoUTF16(preferred, aCharset);
}
}
}

Просмотреть файл

@ -114,7 +114,7 @@ NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsACString& aAlias,
// string bundles use UTF8 keys
nsAutoString result;
nsresult rv = mDelegate->Get(NS_ConvertASCIItoUCS2(aKey), result);
oResult = NS_LossyConvertUCS2toASCII(result);
LossyAppendUTF16toASCII(result, oResult);
return rv;
}

Просмотреть файл

@ -182,13 +182,13 @@ nsresult nsTextToSubURI::convertURItoUnicode(const nsAFlatCString &aCharset,
PRBool isStatefulCharset = statefulCharset(aCharset.get());
if (!isStatefulCharset && IsASCII(aURI)) {
_retval.Assign(NS_ConvertASCIItoUCS2(aURI));
CopyASCIItoUTF16(aURI, _retval);
return rv;
}
if (!isStatefulCharset && aIRI) {
if (IsUTF8(aURI)) {
_retval.Assign(NS_ConvertUTF8toUCS2(aURI));
CopyUTF8toUTF16(aURI, _retval);
return rv;
}
}

Просмотреть файл

@ -66,8 +66,8 @@ static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPat
FSRef rootDirectory;
err = ::FSGetVolumeInfo(0, volumeIndex, NULL, kFSVolInfoNone, NULL, &volName, &rootDirectory);
if (err == noErr) {
nsCString volNameStr = NS_ConvertUCS2toUTF8(Substring((PRUnichar *)volName.unicode,
(PRUnichar *)volName.unicode + volName.length));
NS_ConvertUTF16toUTF8 volNameStr(Substring((PRUnichar *)volName.unicode,
(PRUnichar *)volName.unicode + volName.length));
gVolumeList.AppendCString(volNameStr);
volumeIndex++;
}

2
netwerk/cache/src/nsDiskCacheDevice.cpp поставляемый
Просмотреть файл

@ -205,7 +205,7 @@ NS_IMETHODIMP nsDiskCacheDeviceInfo::GetUsageReport(char ** usageReport)
mDevice->getCacheDirectory(getter_AddRefs(cacheDir));
nsresult rv = cacheDir->GetPath(path);
if (NS_SUCCEEDED(rv)) {
buffer.Append(NS_ConvertUCS2toUTF8(path));
AppendUTF16toUTF8(path, buffer);
} else {
buffer.Append("directory unavailable");
}

Просмотреть файл

@ -515,7 +515,7 @@ nsresult nsIDNService::decodeACE(const nsACString& in, nsACString& out)
nsAutoString utf16;
ucs4toUtf16(output, utf16);
delete [] output;
out.Assign(NS_ConvertUCS2toUTF8(utf16));
CopyUTF16toUTF8(utf16, out);
// Validation: encode back to ACE and compare the strings
nsCAutoString ace;

Просмотреть файл

@ -2242,7 +2242,7 @@ nsFtpState::Init(nsIFTPChannel* aChannel,
if (!uname.IsEmpty() && !uname.Equals(NS_LITERAL_CSTRING("anonymous"))) {
mAnonymous = PR_FALSE;
mUsername = NS_ConvertUTF8toUCS2(NS_UnescapeURL(uname));
CopyUTF8toUTF16(NS_UnescapeURL(uname), mUsername);
// return an error if we find a CR or LF in the username
if (uname.FindCharInSet(CRLF) >= 0)
@ -2254,7 +2254,7 @@ nsFtpState::Init(nsIFTPChannel* aChannel,
if (NS_FAILED(rv))
return rv;
mPassword = NS_ConvertUTF8toUCS2(NS_UnescapeURL(password));
CopyUTF8toUTF16(NS_UnescapeURL(password), mPassword);
// return an error if we find a CR or LF in the password
if (mPassword.FindCharInSet(CRLF) >= 0)

Просмотреть файл

@ -582,7 +582,7 @@ nsHttpChannel::ApplyContentConversions()
// stream converter service.. carry on..
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIStreamListener> converter;
nsAutoString from = NS_ConvertASCIItoUCS2(val);
NS_ConvertASCIItoUTF16 from(val);
ToLowerCase(from);
rv = serv->AsyncConvertData(from.get(),
NS_LITERAL_STRING("uncompressed").get(),

Просмотреть файл

@ -719,11 +719,11 @@ mozTXTToHTMLConv::SmilyHit(const PRUnichar * aInString, PRInt32 aLength, PRBool
outputHTML.Append(PRUnichar(' '));
}
outputHTML += NS_LITERAL_STRING("<img src=\"chrome://editor/content/images/")
+ NS_ConvertASCIItoUCS2(imageName)
+ NS_LITERAL_STRING("\" alt=\"")
+ NS_ConvertASCIItoUCS2(tagTXT)
+ NS_LITERAL_STRING("\" class=\"moz-txt-smily\"height=19 width=19 align=ABSCENTER>");
outputHTML += NS_LITERAL_STRING("<img src=\"chrome://editor/content/images/");
AppendASCIItoUTF16(imageName, outputHTML);
outputHTML += NS_LITERAL_STRING("\" alt=\"");
AppendASCIItoUTF16(tagTXT, outputHTML);
outputHTML += NS_LITERAL_STRING("\" class=\"moz-txt-smily\"height=19 width=19 align=ABSCENTER>");
glyphTextLen = (col0 ? 0 : 1) + tagLen;
return PR_TRUE;
}

Просмотреть файл

@ -241,7 +241,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
}
nsString buffer;
buffer.Assign(NS_LITERAL_STRING("<?xml version=\"1.0\""));
buffer.Assign(NS_LITERAL_STRING("<?xml version=\"1.0\" encoding=\""));
// Get the encoding from the parser
// XXX - this won't work for any encoding set via a 301: line in the
@ -253,11 +253,9 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
rv = mParser->GetEncoding(getter_Copies(encoding));
if (NS_FAILED(rv)) return rv;
buffer.Append(NS_LITERAL_STRING(" encoding=\"") +
NS_ConvertASCIItoUCS2(encoding) +
NS_LITERAL_STRING("\""));
AppendASCIItoUTF16(encoding, buffer);
buffer.Append(NS_LITERAL_STRING("?>\n") +
buffer.Append(NS_LITERAL_STRING("\"?>\n") +
NS_LITERAL_STRING("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" ") +
NS_LITERAL_STRING("\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"));
@ -335,9 +333,9 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
if (NS_FAILED(rv)) return rv;
ConvertNonAsciiToNCR(parentText, strNCR);
buffer.Append(NS_LITERAL_STRING("<tr><td colspan=\"3\"><a href=\"") +
NS_ConvertASCIItoUCS2(parentStr) +
NS_LITERAL_STRING("\">") +
buffer.Append(NS_LITERAL_STRING("<tr><td colspan=\"3\"><a href=\""));
AppendASCIItoUTF16(parentStr, buffer);
buffer.Append(NS_LITERAL_STRING("\">") +
strNCR +
NS_LITERAL_STRING("</a></td></tr>\n"));
}
@ -510,7 +508,7 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest,
}
NS_EscapeURL(utf8UnEscapeSpec.get(), utf8UnEscapeSpec.Length(), escFlags, escapeBuf);
pushBuffer.Append(NS_ConvertUTF8toUCS2(escapeBuf));
AppendUTF8toUTF16(escapeBuf, pushBuffer);
pushBuffer.Append(NS_LITERAL_STRING("\"><img src=\""));

Просмотреть файл

@ -388,7 +388,7 @@ nsRDFXMLSerializer::SerializeChildAssertion(nsIOutputStream* aStream,
const char *s;
resource->GetValueConst(&s);
nsAutoString uri = NS_ConvertUTF8toUCS2(s);
NS_ConvertUTF8toUTF16 uri(s);
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mBaseURLSpec.get()), uri);
rdf_EscapeAttributeValue(uri);
@ -536,7 +536,7 @@ static const char kRDFDescriptionClose[] = " </RDF:Description>\n";
rv = aResource->GetValueConst(&s);
if (NS_FAILED(rv)) return rv;
nsAutoString uri = NS_ConvertUTF8toUCS2(s);
NS_ConvertUTF8toUTF16 uri(s);
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mBaseURLSpec.get()), uri);
rdf_EscapeAttributeValue(uri);
@ -699,7 +699,7 @@ static const char kRDFLIOpen[] = " <RDF:li";
static const char kRDFLIResource1[] = " resource=\"";
static const char kRDFLIResource2[] = "\"/>\n";
nsAutoString uri = NS_ConvertUTF8toUCS2(s);
NS_ConvertUTF8toUTF16 uri(s);
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mBaseURLSpec.get()), uri);
rdf_EscapeAttributeValue(uri);
@ -797,7 +797,7 @@ nsRDFXMLSerializer::SerializeContainer(nsIOutputStream* aStream,
const char *s;
if (NS_SUCCEEDED(aContainer->GetValueConst(&s))) {
nsAutoString uri = NS_ConvertUTF8toUCS2(s);
NS_ConvertUTF8toUTF16 uri(s);
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mBaseURLSpec.get()), uri);
rdf_EscapeAttributeValue(uri);

Просмотреть файл

@ -1379,7 +1379,7 @@ nsChromeRegistry::FollowArc(nsIRDFDataSource *aDataSource,
const PRUnichar *s;
rv = literal->GetValueConst(&s);
if (NS_FAILED(rv)) return rv;
aResult.Assign(NS_ConvertUCS2toUTF8(s));
CopyUTF16toUTF8(s, aResult);
}
else {
// This should _never_ happen.

Просмотреть файл

@ -1633,7 +1633,7 @@ FileSystemDataSource::GetName(nsIRDFResource *source, nsIRDFLiteral **aResult)
0, beNameAttr, sizeof(beNameAttr)-1)) > 0)
{
beNameAttr[len] = '\0';
name = NS_ConvertUTF8toUCS2(beNameAttr);
CopyUTF8toUTF16(beNameAttr, name);
rv = NS_OK;
}
}
@ -1643,7 +1643,7 @@ FileSystemDataSource::GetName(nsIRDFResource *source, nsIRDFLiteral **aResult)
nsCAutoString leafName;
rv = aFileLocal->GetNativeLeafName(leafName);
if (NS_SUCCEEDED(rv)) {
name = NS_ConvertUTF8toUCS2(leafName);
CopyUTF8toUTF16(leafName, name);
rv = NS_OK;
}
}

Просмотреть файл

@ -201,7 +201,7 @@ nsOSHelperAppService::UnescapeCommand(const nsAString& aEscapedCommand,
LOG(("UnescapeCommand really needs some work -- it should actually do some unescaping\n"));
aUnEscapedCommand = NS_ConvertUCS2toUTF8(aEscapedCommand);
CopyUTF16toUTF8(aEscapedCommand, aUnEscapedCommand);
LOG(("Escaped command: '%s'\n",
PromiseFlatCString(aUnEscapedCommand).get()));
return NS_OK;

Просмотреть файл

@ -142,7 +142,7 @@ nsOSHelperAppService::UnescapeCommand(const nsAString& aEscapedCommand,
LOG(("UnescapeCommand really needs some work -- it should actually do some unescaping\n"));
aUnEscapedCommand = NS_ConvertUCS2toUTF8(aEscapedCommand);
CopyUTF16toUTF8(aEscapedCommand, aUnEscapedCommand);
LOG(("Escaped command: '%s'\n",
PromiseFlatCString(aUnEscapedCommand).get()));
return NS_OK;

Просмотреть файл

@ -2043,7 +2043,7 @@ nsBrowserWindow::OnProgress(nsIRequest* request, nsISupports *ctxt,
if (nsnull != aURL) {
nsCAutoString str;
aURL->GetSpec(str);
url = NS_ConvertUTF8toUCS2(str);
AppendUTF8toUTF16(str, url);
}
url.Append(NS_LITERAL_STRING(": progress "));
url.AppendInt(aProgress, 10);

Просмотреть файл

@ -1098,7 +1098,7 @@ nsViewerApp::CreateRobot(nsBrowserWindow* aWindow)
{
nsString* tempStr = new nsString;
if ( tempStr )
tempStr->Assign(NS_ConvertUTF8toUCS2(str));
CopyUTF8toUTF16(str, *tempStr);
gWorkList->AppendElement(tempStr);
}
#if defined(XP_WIN) && defined(NS_DEBUG)