Reactos
at master 127 lines 3.1 kB view raw
1/*** 2*mbclevel.c - Tests if char is hiragana, katakana, alphabet or digit. 3* 4* Copyright (c) Microsoft Corporation. All rights reserved. 5* 6*Purpose: 7* Tests for the various industry defined levels of Microsoft Kanji 8* Code. 9* 10*******************************************************************************/ 11#ifndef _MBCS 12 #error This file should only be compiled with _MBCS defined 13#endif 14 15#include <corecrt_internal_mbstring.h> 16#include <locale.h> 17 18 19/*** 20*int _ismbcl0(c) - Tests if char is hiragana, katakana, alphabet or digit. 21* 22*Purpose: 23* Tests if a given char is hiragana, katakana, alphabet, digit or symbol 24* of Microsoft Kanji code. 25* 26*Entry: 27* unsigned int c - Character to test. 28* 29*Exit: 30* Returns non-zero if 0x8140 <= c <= 0x889E, else 0. 31* 32*Exceptions: 33* 34*******************************************************************************/ 35 36extern "C" int __cdecl _ismbcl0_l( 37 unsigned int c, 38 _locale_t plocinfo 39 ) 40{ 41 _LocaleUpdate _loc_update(plocinfo); 42 43 return( (_loc_update.GetLocaleT()->mbcinfo->mbcodepage == _KANJI_CP) && 44 (_ismbblead_l(c >> 8, _loc_update.GetLocaleT())) && 45 (_ismbbtrail_l(c & 0x0ff, _loc_update.GetLocaleT())) && 46 (c < 0x889f) ); 47} 48 49extern "C" int (__cdecl _ismbcl0)( 50 unsigned int c 51 ) 52{ 53 return _ismbcl0_l(c, nullptr); 54} 55 56 57/*** 58*int _ismbcl1(c) - Tests for 1st-level Microsoft Kanji code set. 59* 60*Purpose: 61* Tests if a given char belongs to Microsoft 1st-level Kanji code set. 62* 63*Entry: 64* unsigned int c - character to test. 65* 66*Exit: 67* Returns non-zero if 1st-level, else 0. 68* 69*Exceptions: 70* 71*******************************************************************************/ 72 73extern "C" int __cdecl _ismbcl1_l( 74 unsigned int c, 75 _locale_t plocinfo 76 ) 77{ 78 _LocaleUpdate _loc_update(plocinfo); 79 80 return( (_loc_update.GetLocaleT()->mbcinfo->mbcodepage == _KANJI_CP) && 81 (_ismbblead_l(c >> 8, _loc_update.GetLocaleT())) && 82 (_ismbbtrail_l(c & 0x0ff, _loc_update.GetLocaleT())) && 83 (c >= 0x889f) && (c <= 0x9872) ); 84} 85 86extern "C" int (__cdecl _ismbcl1)( 87 unsigned int c 88 ) 89{ 90 return _ismbcl1_l(c, nullptr); 91} 92 93 94/*** 95*int _ismbcl2(c) - Tests for a 2nd-level Microsoft Kanji code character. 96* 97*Purpose: 98* Tests if a given char belongs to the Microsoft 2nd-level Kanji code set. 99* 100*Entry: 101* unsigned int c - character to test. 102* 103*Exit: 104* Returns non-zero if 2nd-level, else 0. 105* 106*Exceptions: 107* 108*******************************************************************************/ 109 110extern "C" int __cdecl _ismbcl2_l( 111 unsigned int c, 112 _locale_t plocinfo 113 ) 114{ 115 _LocaleUpdate _loc_update(plocinfo); 116 117 return( (_loc_update.GetLocaleT()->mbcinfo->mbcodepage == _KANJI_CP) && 118 (_ismbblead_l(c >> 8, _loc_update.GetLocaleT())) && 119 (_ismbbtrail_l(c & 0x0ff, _loc_update.GetLocaleT())) && 120 (c >= 0x989f) && (c <= 0xEAA4) ); 121} 122extern "C" int __cdecl _ismbcl2( 123 unsigned int c 124 ) 125{ 126 return _ismbcl2_l(c, nullptr); 127}