character_code_conversion.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright 2016 Andrey Semashev
  3. *
  4. * Distributed under the Boost Software License, Version 1.0.
  5. * See http://www.boost.org/LICENSE_1_0.txt
  6. */
  7. #ifndef BOOST_WINAPI_CHARACTER_CODE_CONVERSION_HPP_INCLUDED_
  8. #define BOOST_WINAPI_CHARACTER_CODE_CONVERSION_HPP_INCLUDED_
  9. #include <boost/winapi/basic_types.hpp>
  10. #include <boost/winapi/detail/header.hpp>
  11. #ifdef BOOST_HAS_PRAGMA_ONCE
  12. #pragma once
  13. #endif
  14. #if !defined( BOOST_USE_WINDOWS_H )
  15. extern "C" {
  16. BOOST_WINAPI_IMPORT_EXCEPT_WM int BOOST_WINAPI_WINAPI_CC
  17. MultiByteToWideChar(
  18. boost::winapi::UINT_ CodePage,
  19. boost::winapi::DWORD_ dwFlags,
  20. boost::winapi::LPCSTR_ lpMultiByteStr,
  21. int cbMultiByte,
  22. boost::winapi::LPWSTR_ lpWideCharStr,
  23. int cchWideChar);
  24. BOOST_WINAPI_IMPORT_EXCEPT_WM int BOOST_WINAPI_WINAPI_CC
  25. WideCharToMultiByte(
  26. boost::winapi::UINT_ CodePage,
  27. boost::winapi::DWORD_ dwFlags,
  28. boost::winapi::LPCWSTR_ lpWideCharStr,
  29. int cchWideChar,
  30. boost::winapi::LPSTR_ lpMultiByteStr,
  31. int cbMultiByte,
  32. boost::winapi::LPCSTR_ lpDefaultChar,
  33. boost::winapi::LPBOOL_ lpUsedDefaultChar);
  34. } // extern "C"
  35. #endif // #if !defined( BOOST_USE_WINDOWS_H )
  36. namespace boost {
  37. namespace winapi {
  38. #if defined( BOOST_USE_WINDOWS_H )
  39. BOOST_CONSTEXPR_OR_CONST UINT_ CP_ACP_ = CP_ACP;
  40. BOOST_CONSTEXPR_OR_CONST UINT_ CP_OEMCP_ = CP_OEMCP;
  41. BOOST_CONSTEXPR_OR_CONST UINT_ CP_MACCP_ = CP_MACCP;
  42. BOOST_CONSTEXPR_OR_CONST UINT_ CP_THREAD_ACP_ = CP_THREAD_ACP;
  43. BOOST_CONSTEXPR_OR_CONST UINT_ CP_SYMBOL_ = CP_SYMBOL;
  44. BOOST_CONSTEXPR_OR_CONST UINT_ CP_UTF7_ = CP_UTF7;
  45. BOOST_CONSTEXPR_OR_CONST UINT_ CP_UTF8_ = CP_UTF8;
  46. BOOST_CONSTEXPR_OR_CONST DWORD_ MB_PRECOMPOSED_ = MB_PRECOMPOSED;
  47. BOOST_CONSTEXPR_OR_CONST DWORD_ MB_COMPOSITE_ = MB_COMPOSITE;
  48. BOOST_CONSTEXPR_OR_CONST DWORD_ MB_USEGLYPHCHARS_ = MB_USEGLYPHCHARS;
  49. BOOST_CONSTEXPR_OR_CONST DWORD_ MB_ERR_INVALID_CHARS_ = MB_ERR_INVALID_CHARS;
  50. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_COMPOSITECHECK_ = WC_COMPOSITECHECK;
  51. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_DISCARDNS_ = WC_DISCARDNS;
  52. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_SEPCHARS_ = WC_SEPCHARS;
  53. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_DEFAULTCHAR_ = WC_DEFAULTCHAR;
  54. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K
  55. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_NO_BEST_FIT_CHARS_ = WC_NO_BEST_FIT_CHARS;
  56. #endif
  57. #else // defined( BOOST_USE_WINDOWS_H )
  58. BOOST_CONSTEXPR_OR_CONST UINT_ CP_ACP_ = 0u;
  59. BOOST_CONSTEXPR_OR_CONST UINT_ CP_OEMCP_ = 1u;
  60. BOOST_CONSTEXPR_OR_CONST UINT_ CP_MACCP_ = 2u;
  61. BOOST_CONSTEXPR_OR_CONST UINT_ CP_THREAD_ACP_ = 3u;
  62. BOOST_CONSTEXPR_OR_CONST UINT_ CP_SYMBOL_ = 42u;
  63. BOOST_CONSTEXPR_OR_CONST UINT_ CP_UTF7_ = 65000u;
  64. BOOST_CONSTEXPR_OR_CONST UINT_ CP_UTF8_ = 65001u;
  65. BOOST_CONSTEXPR_OR_CONST DWORD_ MB_PRECOMPOSED_ = 0x00000001;
  66. BOOST_CONSTEXPR_OR_CONST DWORD_ MB_COMPOSITE_ = 0x00000002;
  67. BOOST_CONSTEXPR_OR_CONST DWORD_ MB_USEGLYPHCHARS_ = 0x00000004;
  68. BOOST_CONSTEXPR_OR_CONST DWORD_ MB_ERR_INVALID_CHARS_ = 0x00000008;
  69. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_COMPOSITECHECK_ = 0x00000200;
  70. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_DISCARDNS_ = 0x00000010;
  71. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_SEPCHARS_ = 0x00000020;
  72. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_DEFAULTCHAR_ = 0x00000040;
  73. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K
  74. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_NO_BEST_FIT_CHARS_ = 0x00000400;
  75. #endif
  76. #endif // defined( BOOST_USE_WINDOWS_H )
  77. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  78. // This constant is not present in MinGW
  79. BOOST_CONSTEXPR_OR_CONST DWORD_ WC_ERR_INVALID_CHARS_ = 0x00000080;
  80. #endif
  81. using ::MultiByteToWideChar;
  82. using ::WideCharToMultiByte;
  83. } // namespace winapi
  84. } // namespace boost
  85. #include <boost/winapi/detail/footer.hpp>
  86. #endif // BOOST_WINAPI_CHARACTER_CODE_CONVERSION_HPP_INCLUDED_