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.

59 lines
1.5 KiB

  1. /***
  2. *ismblgl.c - Tests to see if a given character is a legal MBCS char.
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Tests to see if a given character is a legal MBCS character.
  8. *
  9. *Revision History:
  10. * 11-19-92 KRS Ported from 16-bit sources.
  11. * 10-05-93 GJF Replaced _CRTAPI1 with __cdecl.
  12. * 04-01-98 GJF Implemented multithread support based on threadmbcinfo
  13. * structs
  14. *
  15. *******************************************************************************/
  16. #ifdef _MBCS
  17. #include <mtdll.h>
  18. #include <cruntime.h>
  19. #include <mbdata.h>
  20. #include <mbctype.h>
  21. #include <mbstring.h>
  22. /***
  23. *int _ismbclegal(c) - tests for a valid MBCS character.
  24. *
  25. *Purpose:
  26. * Tests to see if a given character is a legal MBCS character.
  27. *
  28. *Entry:
  29. * unsigned int c - character to test
  30. *
  31. *Exit:
  32. * returns non-zero if Microsoft Kanji code, else 0
  33. *
  34. *Exceptions:
  35. *
  36. ******************************************************************************/
  37. int __cdecl _ismbclegal(
  38. unsigned int c
  39. )
  40. {
  41. #ifdef _MT
  42. pthreadmbcinfo ptmbci = _getptd()->ptmbcinfo;
  43. if ( ptmbci != __ptmbcinfo )
  44. ptmbci = __updatetmbcinfo();
  45. return( (__ismbblead_mt(ptmbci, c >> 8)) &&
  46. (__ismbbtrail_mt(ptmbci, c & 0x0ff)) );
  47. #else
  48. return( (_ismbblead(c >> 8)) && (_ismbbtrail(c & 0377)) );
  49. #endif
  50. }
  51. #endif /* _MBCS */