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.

85 lines
2.4 KiB

  1. #include "convbase.h"
  2. enum KANA_MODE
  3. {
  4. FULL_MODE = 0,
  5. ESC_MODE = 1,
  6. SIO_MODE = 2,
  7. };
  8. enum JIS_ESC_STATE
  9. {
  10. JIS_ASCII = 0,
  11. JIS_Roman = 1,
  12. JIS_Kana = 2,
  13. JIS_DoubleByte = 3,
  14. };
  15. class CInccJisIn : public CINetCodeConverter
  16. {
  17. private:
  18. BOOL (CInccJisIn::*m_pfnConv)(UCHAR tc);
  19. BOOL (CInccJisIn::*m_pfnCleanUp)();
  20. BOOL m_fShift; /* Shift in/out control */
  21. BOOL m_fJapan; /* IN_JP OUT_JP control */
  22. BOOL m_fLeadByte; /* Shift in and lead byte flag */
  23. UCHAR m_tcLeadByte; /* perserve the last lead byte */
  24. UINT m_nESCBytes; /* # bytes of ESC sequence */
  25. JIS_ESC_STATE m_eEscState; /* State of ESC sequence */
  26. public:
  27. CInccJisIn(UINT uCodePage, int nCodeSet);
  28. ~CInccJisIn() {}
  29. virtual HRESULT ConvertChar(UCHAR tc, int cchSrc=-1);
  30. virtual BOOL CleanUp();
  31. virtual int GetUnconvertBytes();
  32. virtual DWORD GetConvertMode();
  33. virtual void SetConvertMode(DWORD mode);
  34. private:
  35. void Reset();
  36. BOOL ConvMain(UCHAR tc);
  37. BOOL CleanUpMain();
  38. BOOL ConvEsc(UCHAR tc);
  39. BOOL CleanUpEsc();
  40. BOOL ConvIsoIn(UCHAR tc);
  41. BOOL CleanUpIsoIn();
  42. BOOL ConvIsoInJp(UCHAR tc);
  43. BOOL CleanUpIsoInJp();
  44. BOOL ConvIsoOut(UCHAR tc);
  45. BOOL CleanUpIsoOut();
  46. BOOL ConvStar(UCHAR tc);
  47. BOOL CleanUpStar();
  48. BOOL ConvDoubleByte(UCHAR tc);
  49. BOOL CleanUpDoubleByte();
  50. };
  51. class CInccJisOut : public CINetCodeConverter
  52. {
  53. private:
  54. BOOL m_fDoubleByte;
  55. UCHAR m_tcLeadByte; // use for DBCS lead byte
  56. UCHAR m_tcPrevByte; // use for half width kana as a saved previous byte
  57. BOOL m_fKana;
  58. BOOL m_fJapan;
  59. BOOL m_fSaveByte;
  60. DWORD m_dwFlag;
  61. WCHAR *m_lpFallBack;
  62. KANA_MODE m_eKanaMode ; // half width kana convert method
  63. public:
  64. CInccJisOut(UINT uCodePage, int nCodeSet, DWORD dwFlag, WCHAR *lpFallBack);
  65. ~CInccJisOut() {}
  66. virtual HRESULT ConvertChar(UCHAR tc, int cchSrc=-1);
  67. virtual BOOL CleanUp();
  68. virtual int GetUnconvertBytes();
  69. virtual DWORD GetConvertMode();
  70. virtual void SetConvertMode(DWORD mode);
  71. void SetKanaMode(UINT uCodePage);
  72. private:
  73. void Reset();
  74. HRESULT ConvFullWidthKana(UCHAR tc);
  75. BOOL KanaCleanUp();
  76. };