UTF8InputStream::CountValidUTF8Bytes(const char* aBuffer, PRUint32 aMaxBytes, PRUint32& aValidUTF8bytes, PRUint32& aValidUCS2chars)
UTF8InputStream::CountValidUTF8Bytes(const char* aBuffer, PRUint32 aMaxBytes, PRUint32& aValidUTF8bytes, PRUint32& aValidUTF16CodeUnits)
UTF8InputStream::CountValidUTF8Bytes(const char* aBuffer, PRUint32 aMaxBytes, PRUint32& aValidUTF8bytes, PRUint32& aValidUCS2chars){  const char *c = aBuffer;  const char *end = aBuffer + aMaxBytes;  const char *lastchar = c;     // pre-initialize in case of 0-length buffer  PRUint32 ucs2bytes = 0;  while (c < end && *c) {    lastchar = c;    ucs2bytes++;        if (UTF8traits::isASCII(*c))      c++;    else if (UTF8traits::is2byte(*c))      c += 2;    else if (UTF8traits::is3byte(*c))      c += 3;    else if (UTF8traits::is4byte(*c))      c += 4;    else if (UTF8traits::is5byte(*c))      c += 5;    else if (UTF8traits::is6byte(*c))      c += 6;    else {      NS_WARNING("Unrecognized UTF8 string in UTF8InputStream::CountValidUTF8Bytes()");      break; // Otherwise we go into an infinite loop.  But what happens now?    }  }  if (c > end) {    c = lastchar;    ucs2bytes--;  }  aValidUTF8bytes = c - aBuffer;  aValidUCS2chars = ucs2bytes;}