public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Cc: Achim Gratz <Stromeko@nexgo.de>
Subject: Re: [:xdigit:] does not work with std::wstring in a Cygwin environment
Date: Fri, 11 Feb 2022 20:35:51 +0100	[thread overview]
Message-ID: <Yga6l6Gx9PRDGjDS@calimero.vinschen.de> (raw)
In-Reply-To: <53a83ef8dcc847e2914be35aa8c4525a@brillux.de>

On Feb 11 16:02, Gans, Markus wrote:
> 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?
> ------------------------------------------------------------------------------

This seems to be a bug in libstdc++.  None of the above functions call
any internal library function which could affect the result.  That means
regcomp(3), regexec(3), isxdigit{_l}(3) or iswxdigit{_l}(3).

Achim, any idea?  Is wchar support broken in Cygwin's libstdc++, by any
chance?


Corinna

  reply	other threads:[~2022-02-11 19:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 16:02 Gans, Markus
2022-02-11 19:35 ` Corinna Vinschen [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yga6l6Gx9PRDGjDS@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=Stromeko@nexgo.de \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).