зеркало из https://github.com/mozilla/gecko-dev.git
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.
This commit is contained in:
Родитель
983515751e
Коммит
a159b5a1eb
|
@ -47,6 +47,11 @@ NS_COM size_t Distance( const nsReadingIterator<char>&, const nsReadingIterator<
|
|||
|
||||
NS_COM void CopyUCS2toASCII( const nsAString& aSource, nsACString& aDest );
|
||||
NS_COM void CopyASCIItoUCS2( const nsACString& aSource, nsAString& aDest );
|
||||
NS_COM void CopyUCS2toUTF8( const nsAString& aSource, nsACString& aDest );
|
||||
NS_COM void CopyUTF8toUCS2( const nsACString& aSource, nsAString& aDest );
|
||||
|
||||
NS_COM void AppendUCS2toUTF8( const nsAString& aSource, nsACString& aDest );
|
||||
NS_COM void AppendUTF8toUCS2( const nsACString& aSource, nsAString& aDest );
|
||||
|
||||
/**
|
||||
* Returns a new |char| buffer containing a zero-terminated copy of |aSource|.
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -47,6 +47,11 @@ NS_COM size_t Distance( const nsReadingIterator<char>&, const nsReadingIterator<
|
|||
|
||||
NS_COM void CopyUCS2toASCII( const nsAString& aSource, nsACString& aDest );
|
||||
NS_COM void CopyASCIItoUCS2( const nsACString& aSource, nsAString& aDest );
|
||||
NS_COM void CopyUCS2toUTF8( const nsAString& aSource, nsACString& aDest );
|
||||
NS_COM void CopyUTF8toUCS2( const nsACString& aSource, nsAString& aDest );
|
||||
|
||||
NS_COM void AppendUCS2toUTF8( const nsAString& aSource, nsACString& aDest );
|
||||
NS_COM void AppendUTF8toUCS2( const nsACString& aSource, nsAString& aDest );
|
||||
|
||||
/**
|
||||
* Returns a new |char| buffer containing a zero-terminated copy of |aSource|.
|
||||
|
|
|
@ -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).
|
||||
|
|
Загрузка…
Ссылка в новой задаче