fixes bug 124042 "support internationalized URIs" r=dougt, sr=alecf, a=asa

git-svn-id: svn://10.0.0.236/trunk@115936 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
darin%netscape.com
2002-03-06 07:48:55 +00:00
parent d6d2d2537e
commit 04849998e1
373 changed files with 5638 additions and 5259 deletions

View File

@@ -337,6 +337,36 @@ IsASCII( const nsAString& aString )
return PR_TRUE;
}
NS_COM
PRBool
IsASCII( const nsACString& aString )
{
static const char NOT_ASCII = char(~0x7F);
// Don't want to use |copy_string| for this task, since we can stop at the first non-ASCII character
nsACString::const_iterator done_reading;
aString.EndReading(done_reading);
// for each chunk of |aString|...
PRUint32 fragmentLength = 0;
nsACString::const_iterator iter;
for ( aString.BeginReading(iter); iter != done_reading; iter.advance( PRInt32(fragmentLength) ) )
{
fragmentLength = PRUint32(iter.size_forward());
const char* c = iter.get();
const char* fragmentEnd = c + fragmentLength;
// for each character in this chunk...
while ( c < fragmentEnd )
if ( *c++ & NOT_ASCII )
return PR_FALSE;
}
return PR_TRUE;
}
/**