PRUnichar *currentSrcPtr = NS_CONST_CAST(PRUnichar *, originalPtr);
const PRUnichar *currentSrcPtr = originalPtr;
PRBool nsMsgI18Ncheck_data_in_charset_range(const char *charset, const PRUnichar* inString, char **fallbackCharset){  if (!charset || !*charset || !inString || !*inString)    return PR_TRUE;  nsresult res;  PRBool result = PR_TRUE;    nsCOMPtr <nsICharsetConverterManager> ccm = do_GetService(kCharsetConverterManagerCID, &res);  if (NS_SUCCEEDED(res)) {    nsCOMPtr <nsIUnicodeEncoder> encoder;    // get an unicode converter    res = ccm->GetUnicodeEncoderRaw(charset, getter_AddRefs(encoder));    if(NS_SUCCEEDED(res)) {      const PRUnichar *originalPtr = inString;      PRInt32 originalLen = nsCRT::strlen(inString);      PRUnichar *currentSrcPtr = NS_CONST_CAST(PRUnichar *, originalPtr);      char localBuff[512];      PRInt32 consumedLen = 0;      PRInt32 srcLen;      PRInt32 dstLength;      // convert from unicode      while (consumedLen < originalLen) {        srcLen = originalLen - consumedLen;        dstLength = 512;        res = encoder->Convert(currentSrcPtr, &srcLen, localBuff, &dstLength);        if (NS_ERROR_UENC_NOMAPPING == res) {          result = PR_FALSE;          break;        }        else if (NS_FAILED(res) || (0 == dstLength))          break;        currentSrcPtr += srcLen;        consumedLen = currentSrcPtr - originalPtr; // src length used so far      }    }      }  // if the conversion was not successful then try fallback to other charsets  if (!result && fallbackCharset) {    nsXPIDLCString convertedString;    res = nsMsgI18NSaveAsCharset("text/plain", charset, inString,                                  getter_Copies(convertedString), fallbackCharset);    result = (NS_SUCCEEDED(res) && NS_ERROR_UENC_NOMAPPING != res);  }  return result;}