Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsNativeDetectors.cpp File Reference
#include <objbase.h>
#include <mlang.h>
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsNativeCharDetDll.h"
#include "pratom.h"
#include "nsReadableUtils.h"
#include "nsICharsetDetector.h"
#include "nsICharsetDetectionObserver.h"
#include "nsIStringCharsetDetector.h"

Go to the source code of this file.

Classes

class  nsNativeDetector
class  nsNativeStringDetector
class  nsNativeDetectorFactory

Functions

static HRESULT DetectCharsetUsingMLang (IMultiLanguage *aMultiLanguage, IMLangConvertCharset *aMLangConvertCharset, char *charset, nsDetectionConfident &aConfidence, BYTE *inBuf, UINT *inSize)
nsIFactoryNEW_JA_NATIVEDETECTOR_FACTORY ()
nsIFactoryNEW_JA_STRING_NATIVEDETECTOR_FACTORY ()
nsIFactoryNEW_KO_NATIVEDETECTOR_FACTORY ()
nsIFactoryNEW_KO_STRING_NATIVEDETECTOR_FACTORY ()

Function Documentation

static HRESULT DetectCharsetUsingMLang ( IMultiLanguage *  aMultiLanguage,
IMLangConvertCharset *  aMLangConvertCharset,
char *  charset,
nsDetectionConfident aConfidence,
BYTE inBuf,
UINT inSize 
) [static]

Definition at line 59 of file nsNativeDetectors.cpp.

{
  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 = ToNewCString(aCharset);
            PL_strcpy(charset, cstr);
            delete [] cstr;
            aConfidence = eSureAnswer;
          }
        }
      }
      else {
        charset[0] = '\0';
        aConfidence = eNoAnswerMatch;
      }
    }
  }
  return hr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 322 of file nsNativeDetectors.cpp.

                                            {
  return new nsNativeDetectorFactory(50932, PR_FALSE);
}

Definition at line 325 of file nsNativeDetectors.cpp.

                                                   {
  return new nsNativeDetectorFactory(50932, PR_TRUE);
}

Here is the caller graph for this function:

Definition at line 328 of file nsNativeDetectors.cpp.

                                            {
  return new nsNativeDetectorFactory(50949, PR_FALSE);
}

Here is the caller graph for this function:

Definition at line 331 of file nsNativeDetectors.cpp.

                                                   {
  return new nsNativeDetectorFactory(50949, PR_TRUE);
}

Here is the caller graph for this function: