UnicodeStringUtils.h 1.4 KB

12345678910111213141516171819202122232425
  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. #if defined MSWIN
  12. common_strutil_API std::wstring utf8ToWideString(std::string const& utf8String); common_strutil_API std::string wideStringToUtf8(const wchar_t* wideString);
  13. #endif
  14. #if !defined NO_THIRD_PARTY_LIBS
  15. common_strutil_API bool isUtf8(char const* stringToTest); common_strutil_API bool isUtf8Checked(char const* stringToTest, std::string const& sourceFile, int line); common_strutil_API char* strToUtf8(std::string const& inputString);
  16. #endif
  17. }
  18. #if !defined NO_THIRD_PARTY_LIBS
  19. #define REQUIRE_VALID_UTF8_STR(str) REQUIRE(tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  20. #define CHECK_VALID_UTF8_STR(str) ___478(tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  21. #define ENSURE_VALID_UTF8_STR(str) ENSURE(tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  22. #define REQUIRE_VALID_UTF8_STR_OR_NULL(str) REQUIRE((str) == nullptr || tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  23. #define CHECK_VALID_UTF8_STR_OR_NULL(str) ___478((str) == nullptr || tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  24. #define ENSURE_VALID_UTF8_STR_OR_NULL(str) ENSURE((str) == nullptr || tecplot::isUtf8Checked((str), __FILE__, __LINE__))
  25. #endif