Fixing bug 87677. Implementing {Copy,Append}[UCS2|UTF8]to[UTF8|UCS2](). Lame implementations for now, but at least people can start using these methods to avoid double copying all over (this doesn't eliminate the double copy, but it isolates it). r=jaggernaut@netscape.com, sr=alecf@flett.org.

git-svn-id: svn://10.0.0.236/trunk@143132 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%netscape.com
2003-05-31 06:03:18 +00:00
parent 8cd9912ad7
commit 9a2e1fee87
4 changed files with 82 additions and 0 deletions

View File

@@ -176,6 +176,42 @@ CopyASCIItoUCS2( const nsACString& aSource, nsAString& aDest )
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
}
NS_COM
void
CopyUCS2toUTF8( const nsAString& aSource, nsACString& aDest )
{
aDest.Truncate();
AppendUCS2toUTF8(aSource, aDest);
}
NS_COM
void
CopyUTF8toUCS2( const nsACString& aSource, nsAString& aDest )
{
aDest.Truncate();
AppendUTF8toUCS2(aSource, aDest);
}
NS_COM
void
AppendUCS2toUTF8( const nsAString& aSource, nsACString& aDest )
{
// This isn't the fastest possible implementation of this method,
// but it works, and that's better than nothing!
aDest.Append(NS_ConvertUCS2toUTF8(aSource));
}
NS_COM
void
AppendUTF8toUCS2( const nsACString& aSource, nsAString& aDest )
{
// This isn't the fastest possible implementation of this method,
// but it works, and that's better than nothing!
aDest.Append(NS_ConvertUTF8toUCS2(aSource));
}
/**
* A helper function that allocates a buffer of the desired character type big enough to hold a copy of the supplied string (plus a zero terminator).