From dcac74792b036176927c0715f924bf6135620cef Mon Sep 17 00:00:00 2001 From: jaime-m-p <> Date: Tue, 13 Aug 2024 19:58:36 +0200 Subject: [PATCH] Using 32bit wchar_t by default, uint32_t on Windows --- src/unicode.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/unicode.cpp b/src/unicode.cpp index 73b757a79..b7c0fc549 100644 --- a/src/unicode.cpp +++ b/src/unicode.cpp @@ -471,8 +471,16 @@ static std::vector unicode_regex_split_custom(const std::string & text, // std::wregex does not support unicode whitespaces \s: 0x85, 0xA0, 0x001680 ... 0x003000. // std::wregex supports full 32 bit codepoints, not limited to standard max 0x110000. namespace std { - using codepoint = uint32_t; // codepoint type for all template specializations +// codepoint type for all template specializations +#if (WCHAR_MAX > 0xFFFF) + using codepoint = wchar_t; // sizeof(wchar_t) == 4 +#else + using codepoint = uint32_t; // Windows: sizeof(wchar_t) == 2 + #define CUSTOM_CTYPE_CODEPOINT +#endif + +#ifdef CUSTOM_CTYPE_CODEPOINT // Minimal required implementation for std::regex string processing template<> // custom specialized std::ctype class ctype { @@ -530,6 +538,7 @@ namespace std { const std::ctype & use_facet>(const std::locale & loc) { return use_facet>(loc); } +#endif // Minimal required implementation for std::regex string processing template<> // custom specialized std::regex_traits