Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.8 KiB

  1. /*----------------------------------------------------------------------------
  2. %%File: fechmap.c
  3. %%Unit: fechmap
  4. %%Contact: jpick
  5. DLL entry points for FarEast conversion module.
  6. ----------------------------------------------------------------------------*/
  7. #include "private.h"
  8. #include "fechmap_.h"
  9. #include "codepage.h"
  10. static CODEPAGE _mpicetce[icetCount] =
  11. {
  12. CP_EUC_CH, // icetEucCn
  13. CP_EUC_JP, // icetEucJp
  14. CP_EUC_KR, // icetEucKr
  15. CP_UNDEFINED, // icetEucTw (Not externally supported)
  16. CP_UNDEFINED, // icetIso2022Cn (Not externally supported)
  17. CP_ISO_2022_JP, // icetIso2022Jp
  18. CP_ISO_2022_KR, // icetIso2022Kr
  19. CP_UNDEFINED, // icetIso2022Tw (Not externally supported)
  20. CP_TWN, // icetBig5
  21. CP_CHN_GB, // icetGbk
  22. CP_CHN_HZ, // icetHz
  23. CP_JPN_SJ, // icetShiftJis
  24. CP_KOR_5601, // icetWansung
  25. CP_UTF_7, // icetUtf7
  26. CP_UTF_8, // icetUtf8
  27. };
  28. /* C C E D E T E C T I N P U T C O D E */
  29. /*----------------------------------------------------------------------------
  30. %%Function: CceDetectInputCode
  31. %%Contact: jpick
  32. Routine that will analyze contents of file to make a best guess
  33. as to what encoding method was used on it. Caller-supplied get
  34. and unget routines used for data access.
  35. ----------------------------------------------------------------------------*/
  36. EXPIMPL(CCE)
  37. CceDetectInputCode(
  38. IStream *pstmIn, // input stream
  39. DWORD dwFlags, // configuration flags
  40. EFam efPref, // optional: preferred encoding family
  41. int nPrefCp, // optional: preferred code page
  42. UINT *lpCe, // set to detected encoding
  43. BOOL *lpfGuess // set to fTrue if function "guessed"
  44. )
  45. {
  46. CCE cceRet;
  47. ICET icet;
  48. if (!pstmIn || !lpCe || !lpfGuess)
  49. return cceInvalidParameter;
  50. // DEBUG, only. Prepare the assert handler. This macro will
  51. // return cceInternal to the calling app if an assert is hit
  52. // before the handler is cleared, below.
  53. //
  54. // InitAndCatchAsserts();
  55. cceRet = CceDetermineInputType(pstmIn, dwFlags, efPref,
  56. nPrefCp, &icet, lpfGuess);
  57. if ((cceRet == cceSuccess) || (cceRet == cceMayBeAscii))
  58. {
  59. if (_mpicetce[icet] != CP_UNDEFINED )
  60. *lpCe = (UINT) _mpicetce[icet];
  61. else
  62. cceRet = cceUnknownInput;
  63. }
  64. // Done with the assert handler.
  65. //
  66. // ClearAsserts();
  67. return cceRet;
  68. }