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.

81 lines
2.2 KiB

  1. //+-------------------------------------------------------------------------
  2. // Microsoft Windows
  3. //
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: utf8.h
  7. //
  8. // Contents: WideChar (UNICODE) to/from UTF8 APIs
  9. //
  10. // APIs: WideCharToUTF8
  11. // UTF8ToWideChar
  12. //
  13. // History: 19-Feb-97 philh created
  14. //--------------------------------------------------------------------------
  15. #ifndef __UTF8_H__
  16. #define __UTF8_H__
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. //+-------------------------------------------------------------------------
  21. // Maps a wide-character (Unicode) string to a new UTF-8 encoded character
  22. // string.
  23. //
  24. // The wide characters are mapped as follows:
  25. //
  26. // Start End Bits UTF-8 Characters
  27. // ------ ------ ---- --------------------------------
  28. // 0x0000 0x007F 7 0x0xxxxxxx
  29. // 0x0080 0x07FF 11 0x110xxxxx 0x10xxxxxx
  30. // 0x0800 0xFFFF 16 0x1110xxxx 0x10xxxxxx 0x10xxxxxx
  31. //
  32. // The parameter and return value semantics are the same as for the
  33. // Win32 API, WideCharToMultiByte.
  34. //
  35. // Note, starting with NT 4.0, WideCharToMultiByte supports CP_UTF8. CP_UTF8
  36. // isn't supported on Win95.
  37. //--------------------------------------------------------------------------
  38. int
  39. WINAPI
  40. WideCharToUTF8(
  41. IN LPCWSTR lpWideCharStr,
  42. IN int cchWideChar,
  43. OUT LPSTR lpUTF8Str,
  44. IN int cchUTF8
  45. );
  46. //+-------------------------------------------------------------------------
  47. // Maps a UTF-8 encoded character string to a new wide-character (Unicode)
  48. // string.
  49. //
  50. // See CertWideCharToUTF8 for how the UTF-8 characters are mapped to wide
  51. // characters.
  52. //
  53. // The parameter and return value semantics are the same as for the
  54. // Win32 API, MultiByteToWideChar.
  55. //
  56. // If the UTF-8 characters don't contain the expected high order bits,
  57. // ERROR_INVALID_PARAMETER is set and 0 is returned.
  58. //
  59. // Note, starting with NT 4.0, MultiByteToWideChar supports CP_UTF8. CP_UTF8
  60. // isn't supported on Win95.
  61. //--------------------------------------------------------------------------
  62. int
  63. WINAPI
  64. UTF8ToWideChar(
  65. IN LPCSTR lpUTF8Str,
  66. IN int cchUTF8,
  67. OUT LPWSTR lpWideCharStr,
  68. IN int cchWideChar
  69. );
  70. #ifdef __cplusplus
  71. } // Balance extern "C" above
  72. #endif
  73. #endif