char *cstr = aCharset.ToNewCString();
char *cstr = ToNewCString(aCharset);
static HRESULT DetectCharsetUsingMLang(IMultiLanguage *aMultiLanguage, IMLangConvertCharset *aMLangConvertCharset,                                        char* charset, nsDetectionConfident& aConfidence, BYTE* inBuf, UINT* inSize){  if (NULL == charset) {    return E_FAIL;  }  if (*inSize > 4096) {    return E_FAIL;  // Or we could allocate memory on heap  }  aConfidence = eNoAnswerYet;  BYTE outBuf[4096];  UINT outSize = 0;  HRESULT hr = aMLangConvertCharset->DoConversion(inBuf, inSize, outBuf, &outSize);  if (SUCCEEDED(hr)) {    DWORD dwProperty = 0;    UINT sourceCP;    hr = aMLangConvertCharset->GetProperty(&dwProperty);    if (SUCCEEDED(hr)) {      if (dwProperty & MLCONVCHARF_AUTODETECT) {        hr = aMLangConvertCharset->GetSourceCodePage(&sourceCP);        if (SUCCEEDED(hr)) {          MIMECPINFO aCodePageInfo;          hr = aMultiLanguage->GetCodePageInfo(sourceCP, &aCodePageInfo);          if (SUCCEEDED(hr)) {            // convert WCHAR* to char*            nsString aCharset(aCodePageInfo.wszWebCharset);            char *cstr = aCharset.ToNewCString();            PL_strcpy(charset, cstr);            delete [] cstr;            aConfidence = eSureAnswer;          }        }      }      else {        charset[0] = '\0';        aConfidence = eNoAnswerMatch;      }    }  }  return hr;}