public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115524] New: Cygwin: Space character categorized as non-printable by std::ctype<wchar_t>
@ 2024-06-17 14:06 kristian.spangsege at gmail dot com
0 siblings, 0 replies; only message in thread
From: kristian.spangsege at gmail dot com @ 2024-06-17 14:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115524
Bug ID: 115524
Summary: Cygwin: Space character categorized as non-printable
by std::ctype<wchar_t>
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kristian.spangsege at gmail dot com
Target Milestone: ---
Created attachment 58451
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58451&action=edit
test.cpp Demonstrate the bug
On Cygwin, a space character is reported as non-printable by
`std::ctype<wchar_t>` in the "C" locale (the only locale supported by
libstdc+++ on Cygwin). In other words, the following expression evaluates to
`false`:
ctype.is(std::ctype_base::print, ctype.widen(' '))
where `ctype` is obtained by `std::use_facet<std::ctype<wchar_t>>(loc)` and
`loc` is the "C" locale.
It should have been evaluated to `true` because a space character is required
by the C++ standard to be categorized as printable (the defining distinction
between a printable and a graphical character is that space is printable but
not graphical).
Also, the space character is reported as printable by `std::iswprint(int ch)`.
So it seems like the problem is specific to `libstdc++`.
Also, the non-wide space character is reported as printable, i.e,
`std::use_facet<std::ctype<char>>(loc)::is(std::ctype_base::print, ' ')` is
`true`.
Also, `ctype.is(std::ctype_base::print, ctype.widen(' '))` is `true` with
MinGW, with GCC on Linux, and with Visual Studio.
The problem can be demonstrated with the code below (attached as `test.cpp`) in
regular Cygwin (https://cygwin.com/install.html) using GCC 12.3.1 and in the
Cygwin environment of MSYS2 (https://www.msys2.org/) using GCC 13.2.0:
#include <cwctype>
#include <string>
#include <locale>
#include <iostream>
int main()
{
using facet_type = std::ctype<wchar_t>;
std::locale loc;
const auto& ctype = std::use_facet<facet_type>(loc);
wchar_t ch = ctype.widen(' ');
std::cout << ctype.is(ctype.print, ch) << "\n";
std::cout << (std::iswprint(std::char_traits<wchar_t>::to_int_type(ch)) !=
0) << "\n";
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-06-17 14:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-17 14:06 [Bug c++/115524] New: Cygwin: Space character categorized as non-printable by std::ctype<wchar_t> kristian.spangsege at gmail dot com
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).