Encoding.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
  3. #ifndef cmsys_Encoding_h
  4. #define cmsys_Encoding_h
  5. #include <cmsys/Configure.h>
  6. #include <wchar.h>
  7. /* Redefine all public interface symbol names to be in the proper
  8. namespace. These macros are used internally to kwsys only, and are
  9. not visible to user code. Use kwsysHeaderDump.pl to reproduce
  10. these macros after making changes to the interface. */
  11. #if !defined(KWSYS_NAMESPACE)
  12. #define kwsys_ns(x) cmsys##x
  13. #define kwsysEXPORT cmsys_EXPORT
  14. #endif
  15. #if !cmsys_NAME_IS_KWSYS
  16. #define kwsysEncoding kwsys_ns(Encoding)
  17. #define kwsysEncoding_mbstowcs kwsys_ns(Encoding_mbstowcs)
  18. #define kwsysEncoding_DupToWide kwsys_ns(Encoding_DupToWide)
  19. #define kwsysEncoding_wcstombs kwsys_ns(Encoding_wcstombs)
  20. #define kwsysEncoding_DupToNarrow kwsys_ns(Encoding_DupToNarrow)
  21. #endif
  22. #if defined(__cplusplus)
  23. extern "C" {
  24. #endif
  25. /* Convert a narrow string to a wide string.
  26. On Windows, UTF-8 is assumed, and on other platforms,
  27. the current locale is assumed.
  28. */
  29. kwsysEXPORT size_t kwsysEncoding_mbstowcs(wchar_t* dest, const char* src,
  30. size_t n);
  31. /* Convert a narrow string to a wide string.
  32. This can return NULL if the conversion fails. */
  33. kwsysEXPORT wchar_t* kwsysEncoding_DupToWide(const char* src);
  34. /* Convert a wide string to a narrow string.
  35. On Windows, UTF-8 is assumed, and on other platforms,
  36. the current locale is assumed. */
  37. kwsysEXPORT size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* src,
  38. size_t n);
  39. /* Convert a wide string to a narrow string.
  40. This can return NULL if the conversion fails. */
  41. kwsysEXPORT char* kwsysEncoding_DupToNarrow(const wchar_t* str);
  42. #if defined(__cplusplus)
  43. } /* extern "C" */
  44. #endif
  45. /* If we are building a kwsys .c or .cxx file, let it use these macros.
  46. Otherwise, undefine them to keep the namespace clean. */
  47. #if !defined(KWSYS_NAMESPACE)
  48. #undef kwsys_ns
  49. #undef kwsysEXPORT
  50. #if !defined(KWSYS_NAMESPACE) && !cmsys_NAME_IS_KWSYS
  51. #undef kwsysEncoding
  52. #undef kwsysEncoding_mbstowcs
  53. #undef kwsysEncoding_DupToWide
  54. #undef kwsysEncoding_wcstombs
  55. #undef kwsysEncoding_DupToNarrow
  56. #endif
  57. #endif
  58. #endif