X-Recipient: archive-cygwin@delorie.com
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B4C6B3858D1E
Authentication-Results: sourceware.org;
 dmarc=pass (p=none dis=none) header.from=brillux.de
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=brillux.de
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brillux.de; s=k2;
 t=1644595371; bh=TN2VvhMV6DfLokK98w6SrJZiZjxsLwXy+OT/Pn0zkHw=;
 h=From:To:Subject:Date;
 b=jUwsBnip7aT4vWXSMD41izFzkoAEpYWCDLBquE4MCtXgYL5Ms3x3T3aRqTS2ljPnJ
 6Os3DWeZAd5EnOAvO2T/p60cG/fmCWwF2Eq6YupU57i+nXDI1ciHW3L43IL93UOk1Z
 0LRvOgploWXdrWyGrtefZQ8fS0nxVnNo2zanrXdVU5LVFqEnRBFHOmDzxY7X4B88Gr
 NjySG81tmi2NZGXQy8kK9kUqUM8d3pjRBHjZcvry4thk8flHYO7BW871/oWTRIp6LW
 6UewRXwZ20x52Mzvz0Y7+zmrDEZx9zWltLixoEjnZS1HQXDOlz2qlOMYRae+DnWQ/X
 y29qeGn/qHISg==
From: "Gans, Markus" <m.gans@brillux.de>
To: "'cygwin@cygwin.com'" <cygwin@cygwin.com>
Subject: [:xdigit:] does not work with std::wstring in a Cygwin environment
Thread-Topic: [:xdigit:] does not work with std::wstring in a Cygwin
 environment
Thread-Index: AdgfX7MgQ8NBn+2iR8au0QqKCrtABg==
Date: Fri, 11 Feb 2022 16:02:50 +0000
Message-ID: <53a83ef8dcc847e2914be35aa8c4525a@brillux.de>
Accept-Language: de-DE, en-US
Content-Language: de-DE
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [172.20.1.143]
MIME-Version: 1.0
X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS,
 RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS,
 T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@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?
------------------------------------------------------------------------------



-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
