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.

193 lines
7.8 KiB

  1. //
  2. // ucutil.h
  3. //
  4. #ifndef UCUTIL_H
  5. #define UCUTIL_H
  6. /* C O N V E R T S T R W T O A */
  7. /*------------------------------------------------------------------------------
  8. ------------------------------------------------------------------------------*/
  9. __inline int ConvertStrWtoA( LPCWSTR pwch, int cwch, LPSTR pch, int cch, UINT cpg = CP_ACP )
  10. {
  11. return WideCharToMultiByte( cpg, 0, pwch, cwch, pch, cch, NULL, NULL );
  12. }
  13. /* C O N V E R T S T R A T O W */
  14. /*------------------------------------------------------------------------------
  15. ------------------------------------------------------------------------------*/
  16. __inline int ConvertStrAtoW( LPCSTR pch, int cch, LPWSTR pwch, int cwch, UINT cpg = CP_ACP )
  17. {
  18. return MultiByteToWideChar( cpg, 0, pch, cch, pwch, cwch );
  19. }
  20. UINT CpgFromChs( BYTE chs );
  21. void ConvertLogFontWtoA( CONST LOGFONTW *plfW, LOGFONTA *plfA );
  22. void ConvertLogFontAtoW( CONST LOGFONTA *plfA, LOGFONTW *plfW );
  23. // Unicode Character Block Description
  24. #define UNICODE_C0_CONTROL_START 0x0000
  25. #define UNICODE_C0_CONTROL_END 0x001f
  26. #define UNICODE_BASIC_LATIN_START 0x0020
  27. #define UNICODE_BASIC_LATIN_END 0x007f
  28. #define UNICODE_LATIN1_SUPPLEMENT_START 0x0080
  29. #define UNICODE_LATIN1_SUPPLEMENT_END 0x00FF
  30. #define UNICODE_LATIN_EXTENDED_A_START 0x0100
  31. #define UNICODE_LATIN_EXTENDED_A_END 0x017F
  32. #define UNICODE_LATIN_EXTENDED_B_START 0x0180
  33. #define UNICODE_LATIN_EXTENDED_B_END 0x024F
  34. #define UNICODE_IPA_EXTENSIONS_START 0x0250
  35. #define UNICODE_IPA_EXTENSIONS_END 0x02AF
  36. #define UNICODE_SPACING_MODIFIER_LETTERS_START 0x02B0
  37. #define UNICODE_SPACING_MODIFIER_LETTERS_END 0x02FF
  38. #define UNICODE_COMBINING_DIACRITICAL_MARKS_START 0x0300
  39. #define UNICODE_COMBINING_DIACRITICAL_MARKS_END 0x036F
  40. #define UNICODE_GREEK_START 0x0370
  41. #define UNICODE_GREEK_END 0x03FF
  42. #define UNICODE_CYRILLIC_START 0x0400
  43. #define UNICODE_CYRILLIC_END 0x04FF
  44. #define UNICODE_ARMENIAN_START 0x0530
  45. #define UNICODE_ARMENIAN_END 0x058F
  46. #define UNICODE_HEBREW_START 0x0590
  47. #define UNICODE_HEBREW_END 0x05FF
  48. #define UNICODE_ARABIC_START 0x0600
  49. #define UNICODE_ARABIC_END 0x06FF
  50. #define UNICODE_DEVANAGARI_START 0x0900
  51. #define UNICODE_DEVANAGARI_END 0x097F
  52. #define UNICODE_BENGALI_START 0x0980
  53. #define UNICODE_BENGALI_END 0x09FF
  54. #define UNICODE_THAI_START 0x0E00
  55. #define UNICODE_THAI_END 0x0E7F
  56. #define UNICODE_TIBETAN_START 0x0F00
  57. #define UNICODE_TIBETAN_END 0x0FBF
  58. #define UNICODE_HANGUL_JAMO_START 0x1100
  59. #define UNICODE_HANGUL_JAMO_END 0x11FF
  60. #define UNICODE_GENERAL_PUNCTUATION_START 0x2000
  61. #define UNICODE_GENERAL_PUNCTUATION_END 0x206F
  62. #define UNICODE_SUPERSCRIPTS_AND_SUBSCRIPTS_START 0x2070
  63. #define UNICODE_SUPERSCRIPTS_AND_SUBSCRIPTS_END 0x209F
  64. #define UNICODE_CURRENCY_SYMBOLS_START 0x20A0
  65. #define UNICODE_CURRENCY_SYMBOLS_END 0x20CF
  66. #define UNICODE_LETTERLIKE_SYMBOLS_START 0x2100
  67. #define UNICODE_LETTERLIKE_SYMBOLS_END 0x214F
  68. #define UNICODE_NUMBER_FORMS_START 0x2150
  69. #define UNICODE_NUMBER_FORMS_END 0x218F
  70. #define UNICODE_ARROWS_START 0x2190
  71. #define UNICODE_ARROWS_END 0x21FF
  72. #define UNICODE_MATH_OPERATORS_START 0x2200
  73. #define UNICODE_MATH_OPERATORS_END 0x22FF
  74. #define UNICODE_MISC_TECHNICAL_START 0x2300
  75. #define UNICODE_MISC_TECHNICAL_END 0x23FF
  76. #define UNICODE_CONTROL_PICTURES_START 0x2400
  77. #define UNICODE_CONTROL_PICTURES_END 0x243F
  78. #define UNICODE_OCR_START 0x2440
  79. #define UNICODE_OCR_END 0x245F
  80. #define UNICODE_ENCLOSED_ALPHANUMERICS_START 0x2460
  81. #define UNICODE_ENCLOSED_ALPHANUMERICS_END 0x24FF
  82. #define UNICODE_BOX_DRAWING_START 0x2500
  83. #define UNICODE_BOX_DRAWING_END 0x257F
  84. #define UNICODE_BLOCK_ELEMENTS_START 0x2580
  85. #define UNICODE_BLOCK_ELEMENT_END 0x259F
  86. #define UNICODE_GEOMETRIC_SHAPE_START 0x25A0
  87. #define UNICODE_GEOMETRIC_SHAPE_END 0x25FF
  88. #define UNICODE_MISC_SYMBOLS_START 0x2600
  89. #define UNICODE_MISC_SYMBOLD_END 0x26FF
  90. #define UNICODE_CJK_SYMBOLS_AND_PUNCTUATIONS_START 0x3000
  91. #define UNICODE_CJK_SYMBOLS_AND_PUNCTUATIONS_END 0x303F
  92. #define UNICODE_HIRAGANA_START 0x3040
  93. #define UNICODE_HIRAGANA_END 0x309F
  94. #define UNICODE_KATAKANA_START 0x30A0
  95. #define UNICODE_KATAKANA_END 0x30FF
  96. #define UNICODE_BOPOMOFO_START 0x3100
  97. #define UNICODE_BOPOMOFO_END 0x312F
  98. #define UNICODE_HANGUL_COMPATIBILITY_JAMO_START 0x3130
  99. #define UNICODE_HANGUL_COMPATIBILITY_JAMO_END 0x318F
  100. #define UNICODE_KANBUN_START 0x3190
  101. #define UNICODE_KANBUN_END 0x319F
  102. #define UNICODE_ENCLOSED_CJK_LETTERS_AND_MONTHS_START 0x3200
  103. #define UNICODE_NCLOSED_CJK_LETTERS_AND_MONTHS_END 0x32FF
  104. #define UNICODE_CJK_COMPATIBILITY_START 0x3300
  105. #define UNICODE_CJK_COMPATIBILITY_END 0x33FF
  106. #define UNICODE_CJK_UNIFIED_IDEOGRAPHS_START 0x4E00
  107. #define UNICODE_CJK_UNIFIED_IDEOGRAPHS_END 0x9FFF
  108. #define UNICODE_HANGUL_SYLLABLES_START 0xAC00
  109. #define UNICODE_HANGUL_SYLLABLES_END 0xD7A3
  110. #define UNICODE_CJK_COMPATIBILITY_IDEOGRAPHS_START 0xF900
  111. #define UNICODE_CJK_COMPATIBILITY_IDEOGRAPHS_END 0xFAFF
  112. #define UNICODE_FULLWIDTH_ASCII_START 0xFF01
  113. #define UNICODE_FULLWIDTH_ASCII_END 0xFF5E
  114. #define UNICODE_HALFWIDTH_CJK_PUNCTUATION_START 0xFF61
  115. #define UNICODE_HALFWIDTH_CJK_PUNCTUATION_END 0xFF64
  116. #define UNICODE_HALFWIDTH_KATAKANA_START 0xFF65
  117. #define UNICODE_HALFWIDTH_KATAKANA_END 0xFF9F
  118. #define UNICODE_HALFWIDTH_HANGUL_JAMO_FILLER 0xFFA0
  119. #define UNICODE_HALFWIDTH_HANGULE_JAMO_START 0xFFA1
  120. #define UNICODE_HALFWIDTH_HANGULE_JAMO_END 0xFFDC
  121. #define UNICODE_FULLWIDTH_PUNCTUATION_AND_CURRENCY_START 0xFFE0
  122. #define UNICODE_FULLWIDTH_PUNCTUATION_AND_CURRENCY_END 0xFFE6
  123. #define UNICODE_HALFWIDTH_FORMS_ARROWS_SHAPES_START 0xFFE8
  124. #define UNICODE_HALFWIDTH_FORMS_ARROWS_SHAPES_END 0xFFEE
  125. /*---------------------------------------------------------------------------
  126. fIsHangulSyllable
  127. ---------------------------------------------------------------------------*/
  128. __inline
  129. BOOL fIsHangulSyllable(WCHAR wcCh)
  130. {
  131. return (wcCh >= UNICODE_HANGUL_SYLLABLES_START &&
  132. wcCh <= UNICODE_HANGUL_SYLLABLES_END);
  133. }
  134. /*---------------------------------------------------------------------------
  135. fIsHangulCompJamo
  136. ---------------------------------------------------------------------------*/
  137. __inline
  138. BOOL fIsHangulCompJamo(WCHAR wcCh)
  139. {
  140. return (wcCh >= UNICODE_HANGUL_COMPATIBILITY_JAMO_START &&
  141. wcCh <= UNICODE_HANGUL_COMPATIBILITY_JAMO_END);
  142. }
  143. /*---------------------------------------------------------------------------
  144. fIsHangul
  145. ---------------------------------------------------------------------------*/
  146. __inline
  147. BOOL fIsHangul(WCHAR wcCh)
  148. {
  149. return (fIsHangulSyllable(wcCh) || fIsHangulCompJamo(wcCh));
  150. }
  151. /*---------------------------------------------------------------------------
  152. fIsHanja
  153. TODO: What about Extenstion-A ?
  154. ---------------------------------------------------------------------------*/
  155. __inline
  156. BOOL fIsHanja(WCHAR wch)
  157. {
  158. if ( (wch >= UNICODE_CJK_UNIFIED_IDEOGRAPHS_START && wch <= UNICODE_CJK_UNIFIED_IDEOGRAPHS_END) ||
  159. (wch >= UNICODE_CJK_COMPATIBILITY_IDEOGRAPHS_START && wch <= UNICODE_CJK_COMPATIBILITY_IDEOGRAPHS_END) )
  160. return TRUE;
  161. else
  162. return FALSE;
  163. }
  164. /*---------------------------------------------------------------------------
  165. fIsHangulOrHanja
  166. ---------------------------------------------------------------------------*/
  167. __inline
  168. BOOL fIsHangulOrHanja(WCHAR wcCh)
  169. {
  170. return (fIsHangul(wcCh) || fIsHanja(wcCh));
  171. }
  172. #endif /* UCUTIL_H */