UnicodeStringUtils.h 1.3 KB

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include "ThirdPartyHeadersBegin.h"
  3. #include <string>
  4. #include "ThirdPartyHeadersEnd.h"
  5. #if defined MAKEARCHIVE
  6. #define common_strutil_API
  7. #else
  8. #include "common_strutil_Exports.h"
  9. #endif
  10. namespace tecplot
  11. {
  12. #if defined MSWIN
  13. common_strutil_API std::wstring utf8ToWideString(std::string const &utf8String);
  14. common_strutil_API std::string wideStringToUtf8(const wchar_t *wideString);
  15. #endif
  16. #if !defined NO_THIRD_PARTY_LIBS
  17. common_strutil_API bool isUtf8(char const *stringToTest);
  18. common_strutil_API bool isUtf8Checked(char const *stringToTest, std::string const &sourceFile, int line);
  19. common_strutil_API char *strToUtf8(std::string const &inputString);
  20. #endif
  21. }
  22. #if !defined NO_THIRD_PARTY_LIBS
  23. #define REQUIRE_VALID_UTF8_STR(str) REQUIRE(tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  24. #define CHECK_VALID_UTF8_STR(str) ___478(tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  25. #define ENSURE_VALID_UTF8_STR(str) ENSURE(tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  26. #define REQUIRE_VALID_UTF8_STR_OR_NULL(str) REQUIRE((str) == nullptr || tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  27. #define CHECK_VALID_UTF8_STR_OR_NULL(str) ___478((str) == nullptr || tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  28. #define ENSURE_VALID_UTF8_STR_OR_NULL(str) ENSURE((str) == nullptr || tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  29. #endif