string.h 351 B

12345678910111213141516
  1. #if __has_include(<unicode/std_string.h>)
  2. #define JVALIDATE_HAS_ICU
  3. #include <unicode/unistr.h>
  4. #endif
  5. namespace jvalidate::detail {
  6. inline size_t length(std::string_view arg) {
  7. #ifdef JVALIDATE_HAS_ICU
  8. icu::UnicodeString ucs = icu::UnicodeString::fromUTF8(icu::StringPiece(arg));
  9. return ucs.countChar32();
  10. #else
  11. return arg.size();
  12. #endif
  13. }
  14. }