ConvertUTF8toUCS2 converter(mUnicharData->GetBuffer());
ConvertUTF8toUTF16 converter(mUnicharData->GetBuffer());
PRInt32 UTF8InputStream::Fill(nsresult * aErrorCode){  if (nsnull == mInput) {    // We already closed the stream!    *aErrorCode = NS_BASE_STREAM_CLOSED;    return -1;  }  NS_ASSERTION(mByteData->GetLength() >= mByteDataOffset, "unsigned madness");  PRUint32 remainder = mByteData->GetLength() - mByteDataOffset;  mByteDataOffset = remainder;  PRInt32 nb = mByteData->Fill(aErrorCode, mInput, remainder);  if (nb <= 0) {    // Because we assume a many to one conversion, the lingering data    // in the byte buffer must be a partial conversion    // fragment. Because we know that we have recieved no more new    // data to add to it, we can't convert it. Therefore, we discard    // it.    return nb;  }  NS_ASSERTION(remainder + nb == mByteData->GetLength(), "bad nb");  // Now convert as much of the byte buffer to unicode as possible  PRUint32 srcLen, dstLen;  CountValidUTF8Bytes(mByteData->GetBuffer(),remainder + nb, srcLen, dstLen);  // the number of UCS2 characters should always be <= the number of  // UTF8 chars  NS_ASSERTION( (remainder+nb >= srcLen), "cannot be longer than out buffer");  NS_ASSERTION(PRInt32(dstLen) <= mUnicharData->GetBufferSize(),               "Ouch. I would overflow my buffer if I wasn't so careful.");  if (PRInt32(dstLen) > mUnicharData->GetBufferSize()) return 0;    ConvertUTF8toUCS2 converter(mUnicharData->GetBuffer());    nsASingleFragmentCString::const_char_iterator start = mByteData->GetBuffer();  nsASingleFragmentCString::const_char_iterator end = mByteData->GetBuffer() + srcLen;              copy_string(start, end, converter);  NS_ASSERTION(converter.Length() == dstLen, "length mismatch");                 mUnicharDataOffset = 0;  mUnicharDataLength = dstLen;  mByteDataOffset = srcLen;    return dstLen;}