Source code of Windows XP (NT5)
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.

127 lines
4.8 KiB

  1. #ifndef __INCLUDE_XJIS
  2. #define __INCLDUE_XJIS
  3. #ifdef __cplusplus
  4. extern "C"
  5. {
  6. #endif
  7. typedef long SYV;
  8. typedef ALC RECMASK;
  9. typedef WORD SYM;
  10. typedef SYM * LPSYM;
  11. #define SyvFromWord(w) ((LONG)(WORD)(w) | 0x00030000)
  12. #define WordFromSyv(syv) ((WORD) (LOWORD((syv))))
  13. #define IsSpecialSYV(syv) (HIWORD((syv))==SYVHI_SPECIAL)
  14. #define IsAnsiSYV(syv) (HIWORD((syv))==SYVHI_ANSI)
  15. #define IsGestureSYV(syv) (HIWORD((syv))==SYVHI_GESTURE)
  16. #define IsKanjiSYV(syv) (HIWORD((syv))==SYVHI_KANJI)
  17. #define RECMASK_LCALPHA ALC_LCALPHA // 0x0001L a..z
  18. #define RECMASK_UCALPHA ALC_UCALPHA // 0x0002L A..Z
  19. #define RECMASK_ALPHA (ALC_LCALPHA | ALC_UCALPHA)
  20. #define RECMASK_NUMERIC ALC_NUMERIC // 0x00000004L // 0..9
  21. #define RECMASK_ALPHANUMERIC (ALC_ALPHA | ALC_NUMERIC)
  22. #define RECMASK_PUNC ALC_PUNC // 0x0008L // !-;`"?()&.,; and backslash
  23. #define RECMASK_MATH ALC_MATH // 0x0010L // %^*()-+={}<>,/.
  24. #define RECMASK_MONETARY ALC_MONETARY // 0x0020L // ,.$ or local
  25. #define RECMASK_OTHER ALC_OTHER // 0x0040L // @#|_~[]
  26. #define RECMASK_ASCII ALC_ASCII // 0x0080L // restrict to 7-bit chars 20..7f
  27. #define RECMASK_WHITE ALC_WHITE // 0x0100L // white space
  28. #define RECMASK_NONPRINT ALC_NONPRINT // 0x0200L // sp tab ret ctrl glyphs
  29. #define RECMASK_DBCS ALC_DBCS // 0x0400L // allow DBCS variety of SBCS
  30. #define RECMASK_JIS1 ALC_JIS1 // 0x0800L // kanji JPN, ShiftJIS 1 only
  31. #define RECMASK_GESTURE ALC_GESTURE // 0x4000L // gestures
  32. #define RECMASK_HIRAGANA ALC_HIRAGANA // 0x00010000L // hiragana JPN
  33. #define RECMASK_KATAKANA ALC_KATAKANA // 0x00020000L // katakana JPN
  34. #define RECMASK_JIS2 ALC_JIS2 // 0x00040000L // ShiftJIS 2+3
  35. #define RECMASK_GLOBALPRIORITY ALC_GLOBALPRIORITY // 0x10000000
  36. //#define RECMASK_DEFAULT 0x00002000
  37. #define RECMASK_NOPRIORITY ALC_NOPRIORITY // 0x00000000L // for alcPriority == none
  38. #define RECMASK_ALL_DEFAULTS (/*RECMASK_DEFAULT |*/ RECMASK_ALPHANUMERIC | RECMASK_WHITE | RECMASK_PUNC | RECMASK_HIRAGANA | RECMASK_KATAKANA | RECMASK_JIS1 | RECMASK_JIS2 | RECMASK_OTHER)
  39. #define RECMASK_FROM_ALC (~ALC_RESERVED & ~ALC_USEBITMAP & ~ALC_ASCII)
  40. #define ALC_FROM_RECMASK (~ALC_RESERVED & ~ALC_GESTURE)
  41. #define RecmaskFromALC(alc) (RECMASK)(RECMASK_FROM_ALC & (RECMASK)(alc))
  42. #define AlcFromRECMASK(rm) (ALC)(ALC_FROM_RECMASK & (ALC)(rm))
  43. #define UnsupportedOrBitmapALC(alc) \
  44. (~((ALC)RECMASK_FROM_ALC) & (alc))
  45. // KANJI STUFF
  46. #define KANJI_MATCHMAX 6
  47. #define TOKEN_FIRST 600
  48. #define TOKEN_LAST 643
  49. #define KANJI_FIRST 0x8141
  50. #define KANJI_LAST 0xfcfc
  51. #define WDBCSRECMASK_FIRST 0x8140
  52. #define WDBCSRECMASK_LAST 0x81A7
  53. #define KANA_FIRSTMAP 0x8340
  54. #define KANA_LASTMAP 0x8393
  55. #define PUNC_FIRSTMAP 0x8140
  56. #define PUNC_LASTMAP 0x8197
  57. #define CHAR_FIRSTSBCS 0x20 // space
  58. #define CHAR_LASTSBCS 0x7E // '~'
  59. #define CHAR_FIRSTKATA 0xA1
  60. #define CHAR_LASTKATA 0xDF
  61. extern const RECMASK rgrecmaskDbcs[];
  62. extern const RECMASK mptokenrecmask[];
  63. extern const WORD mptokenwmatches[][KANJI_MATCHMAX];
  64. #define IsShiftJisLeadByte(b) (((BYTE)0x81 <= (BYTE)(b) && (BYTE)(b) <= (BYTE)0x9f) || \
  65. ((BYTE)0xe0 <= (BYTE)(b) && (BYTE)(b) <= (BYTE)0xfc))
  66. #define IsValidShiftJisWORD(w) \
  67. ((((BYTE)0x81 <= HIBYTE(w) && HIBYTE(w) <= (BYTE)0x9f) || \
  68. ((BYTE)0xe0 <= HIBYTE(w) && HIBYTE(w) <= (BYTE)0xfc)) && \
  69. (((BYTE)0x40 <= LOBYTE(w) && LOBYTE(w) <= (BYTE)0x7e) || \
  70. ((BYTE)0x80 <= LOBYTE(w) && LOBYTE(w) <= (BYTE)0xfc)))
  71. #define RecmaskFromWORD(w) \
  72. (((w) > 0x9872) ? RECMASK_JIS2 : \
  73. ((w) >= 0x889f) ? RECMASK_JIS1 : \
  74. ((w) >= 0x8340) ? RECMASK_KATAKANA : \
  75. ((w) >= 0x829f) ? RECMASK_HIRAGANA : \
  76. ((w) >= 0x8281) ? RECMASK_LCALPHA : \
  77. ((w) >= 0x8260) ? RECMASK_UCALPHA : \
  78. ((w) >= 0x824f) ? RECMASK_NUMERIC : \
  79. ((w) >= WDBCSRECMASK_FIRST && (w) <= WDBCSRECMASK_LAST) ? rgrecmaskDbcs[(w) - WDBCSRECMASK_FIRST] : \
  80. RECMASK_OTHER)
  81. #define RecmaskFromShapeWORD(w) \
  82. (((w) >= TOKEN_FIRST && (w) <= TOKEN_LAST) ? \
  83. mptokenrecmask[(w) - TOKEN_FIRST] : \
  84. RecmaskFromWORD(w))
  85. WORD XJISFromSYV(SYV syv);
  86. BOOL SupportedXJIS(WORD wxjis);
  87. SYV SBCSFromDBCS(wchar_t wDbcs);
  88. const WORD *pwListFromToken(WORD sym);
  89. WORD GetFirstMatch(WORD wDbcs);
  90. UINT IndexFromSYV(SYV syv, UINT maxIndex);
  91. SYV SyvFromIndex(UINT index);
  92. WORD TokenFromWORD(WORD wDbcs);
  93. int IsEnglishCodePoint(int iCode);
  94. int ValidStrokeCount(wchar_t wch, short iStroke);
  95. int NotSuspStrokeCount(wchar_t wch, short iStroke);
  96. #ifdef __cplusplus
  97. };
  98. #endif
  99. #endif //__INCLUDE_XJIS