Encoding.h.in 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*============================================================================
  2. KWSys - Kitware System Library
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef @KWSYS_NAMESPACE@_Encoding_h
  11. #define @KWSYS_NAMESPACE@_Encoding_h
  12. #include <@KWSYS_NAMESPACE@/Configure.h>
  13. #include <wchar.h>
  14. /* Redefine all public interface symbol names to be in the proper
  15. namespace. These macros are used internally to kwsys only, and are
  16. not visible to user code. Use kwsysHeaderDump.pl to reproduce
  17. these macros after making changes to the interface. */
  18. #if !defined(KWSYS_NAMESPACE)
  19. # define kwsys_ns(x) @KWSYS_NAMESPACE@##x
  20. # define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
  21. #endif
  22. #if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  23. # define kwsysEncoding kwsys_ns(Encoding)
  24. # define kwsysEncoding_mbstowcs kwsys_ns(Encoding_mbstowcs)
  25. # define kwsysEncoding_DupToWide kwsys_ns(Encoding_DupToWide)
  26. # define kwsysEncoding_wcstombs kwsys_ns(Encoding_wcstombs)
  27. # define kwsysEncoding_DupToNarrow kwsys_ns(Encoding_DupToNarrow)
  28. #endif
  29. #if defined(__cplusplus)
  30. extern "C"
  31. {
  32. #endif
  33. /* Convert a narrow string to a wide string.
  34. On Windows, UTF-8 is assumed, and on other platforms,
  35. the current locale is assumed.
  36. */
  37. kwsysEXPORT size_t kwsysEncoding_mbstowcs(wchar_t* dest, const char* src, size_t n);
  38. /* Convert a narrow string to a wide string.
  39. This can return NULL if the conversion fails. */
  40. kwsysEXPORT wchar_t* kwsysEncoding_DupToWide(const char* src);
  41. /* Convert a wide string to a narrow string.
  42. On Windows, UTF-8 is assumed, and on other platforms,
  43. the current locale is assumed. */
  44. kwsysEXPORT size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* src, size_t n);
  45. /* Convert a wide string to a narrow string.
  46. This can return NULL if the conversion fails. */
  47. kwsysEXPORT char* kwsysEncoding_DupToNarrow(const wchar_t* str);
  48. #if defined(__cplusplus)
  49. } /* extern "C" */
  50. #endif
  51. /* If we are building a kwsys .c or .cxx file, let it use these macros.
  52. Otherwise, undefine them to keep the namespace clean. */
  53. #if !defined(KWSYS_NAMESPACE)
  54. # undef kwsys_ns
  55. # undef kwsysEXPORT
  56. # if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  57. # undef kwsysEncoding
  58. # undef kwsysEncoding_mbstowcs
  59. # undef kwsysEncoding_DupToWide
  60. # undef kwsysEncoding_wcstombs
  61. # undef kwsysEncoding_DupToNarrow
  62. # endif
  63. #endif
  64. #endif