public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* [:xdigit:] does not work with std::wstring in a Cygwin environment
@ 2022-02-11 16:02 Gans, Markus
  2022-02-11 19:35 ` Corinna Vinschen
  2022-02-13 18:25 ` Achim Gratz
  0 siblings, 2 replies; 5+ messages in thread
From: Gans, Markus @ 2022-02-11 16:02 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'

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?
------------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-17 23:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11 16:02 [:xdigit:] does not work with std::wstring in a Cygwin environment Gans, Markus
2022-02-11 19:35 ` Corinna Vinschen
2022-02-13 18:25 ` Achim Gratz
2022-02-15  1:36   ` Hans-Bernhard Bröker
2022-02-17 23:11     ` Hans-Bernhard Bröker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).