[:xdigit:] does not work with std::wstring in a Cygwin environment

Gans, Markus m.gans@brillux.de
Fri Feb 11 16:02:50 GMT 2022


This seems to be an internal Cygwin error:
https://www.reddit.com/r/cpp_questions/comments/sp52gq/xdigit_does_not_work_with_stdwstring_in_a_cygwin/
------------------------------------------------------------------------------
I have an unexpected behavior with Cygwin for the character class [:xdigit:]. The pattern matching for [:xdigit:] behaves like the pattern matching of [:digit:] when using a wide string. With `std::string` everything works fine.
Example:
 #include <iostream>
 #include <string>
 #include <regex>
 
 int main ()
 {
 std::cout << "Wide character string\n";
 std::wstring w_character = L"a";
 
 if ( regex_match(w_character, std::wregex(L"[[:xdigit:]]")) )
 std::cout << "'" << char(w_character[0]) << "' is a hex digit\n";
 else
 std::cout << "'" << char(w_character[0]) << "' is not a hex digit\n";
 
 std::cout << "----------------------\n"
 << "String with 1 byte character\n";
 std::string character = "a";
 
 if ( regex_match(character, std::regex("[[:xdigit:]]")) )
 std::cout << "'" << char(w_character[0]) << "' is a hex digit\n";
 else
 std::cout << "'" << char(w_character[0]) << "' is not a hex digit\n";
 
 return 0;
 }
Output in a Cygwin environment:
 Wide character string
 'a' is not a hex digit
 ----------------------
 Character string
 'a' is a hex digit
Output on Linux:
 Wide character string
 'a' is a hex digit
 ----------------------
 String with 1 byte character
 'a' is a hex digit
Question: Why does Cygwin not detect the letters a, b, c, d, e, and f as hexadecimal digits in a wide string?
------------------------------------------------------------------------------


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /