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.

83 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1991-1999, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. utf.h
  5. Abstract:
  6. This file contains the header information for the UTF module of NLS.
  7. Revision History:
  8. 02-06-96 JulieB Created.
  9. --*/
  10. //
  11. // Constant Declarations.
  12. //
  13. #ifndef _UTF8_H_
  14. #define _UTF8_H_
  15. #define ASCII 0x007f
  16. #define UTF8_2_MAX 0x07ff // max UTF8 2-byte sequence (32 * 64 = 2048)
  17. #define UTF8_1ST_OF_2 0xc0 // 110x xxxx
  18. #define UTF8_1ST_OF_3 0xe0 // 1110 xxxx
  19. #define UTF8_1ST_OF_4 0xf0 // 1111 xxxx
  20. #define UTF8_TRAIL 0x80 // 10xx xxxx
  21. #define HIGHER_6_BIT(u) ((u) >> 12)
  22. #define MIDDLE_6_BIT(u) (((u) & 0x0fc0) >> 6)
  23. #define LOWER_6_BIT(u) ((u) & 0x003f)
  24. #define BIT7(a) ((a) & 0x80)
  25. #define BIT6(a) ((a) & 0x40)
  26. #define HIGH_SURROGATE_START 0xd800
  27. #define HIGH_SURROGATE_END 0xdbff
  28. #define LOW_SURROGATE_START 0xdc00
  29. #define LOW_SURROGATE_END 0xdfff
  30. #define UCH_SURROGATE_FIRST 0xD800 // First surrogate
  31. #define UCH_HI_SURROGATE_FIRST 0xD800 // First High Surrogate
  32. #define UCH_PV_HI_SURROGATE_FIRST 0xDB80 // <Private Use High Surrogate, First>
  33. #define UCH_PV_HI_SURROGATE_LAST 0xDBFF // <Private Use High Surrogate, Last>
  34. #define UCH_HI_SURROGATE_LAST 0xDBFF // Last High Surrogate
  35. #define UCH_LO_SURROGATE_FIRST 0xDC00 // <Low Surrogate, First>
  36. #define UCH_LO_SURROGATE_LAST 0xDFFF // <Low Surrogate, Last>
  37. #define UCH_SURROGATE_LAST 0xDFFF // Last surrogate
  38. #define IN_RANGE(v, r1, r2) ((r1) <= (v) && (v) <= (r2))
  39. #define UCH_REPLACE 0xFFFD // REPLACEMENT CHARACTER
  40. #define IsSurrogate(ch) IN_RANGE(ch, UCH_SURROGATE_FIRST, UCH_SURROGATE_LAST)
  41. #define IsHighSurrogate(ch) IN_RANGE(ch, UCH_HI_SURROGATE_FIRST, UCH_HI_SURROGATE_LAST)
  42. #define IsLowSurrogate(ch) IN_RANGE(ch, UCH_LO_SURROGATE_FIRST, UCH_LO_SURROGATE_LAST)
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. size_t UTF8ToUnicode(LPCSTR lpSrcStr, LPWSTR lpDestStr, size_t cchDest);
  47. size_t UTF8ToUnicodeCch(LPCSTR lpSrcStr, size_t cchSrc, LPWSTR lpDestStr, size_t cchDest);
  48. size_t UnicodeToUTF8(LPCWSTR lpSrcStr, LPSTR lpDestStr, size_t cchDest);
  49. size_t UnicodeToUTF8Cch(LPCWSTR lpSrcStr, size_t cchSrc, LPSTR lpDestStr, size_t cchDest);
  50. size_t UnicodeLengthOfUTF8 (PCSTR pUTF8);
  51. size_t UTF8LengthOfUnicode (PCWSTR pUni);
  52. size_t UnicodeLengthOfUTF8Cb (PCSTR pUTF8, size_t cbUTF);
  53. size_t UTF8LengthOfUnicodeCch (PCWSTR pUni, size_t cchUni);
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif