C++ Logo

std-proposals

Advanced search

Re: [std-proposals] constexpr tolower, toupper, isalpha

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sun, 6 Jul 2025 13:38:02 +0100
On Thu, Jul 3, 2025 at 10:01 AM Jonathan Wakely wrote:
>
> Meaning that this would fail:
>
> setlocale(LC_ALL, "de_DE.iso8859-1");
> char c uuml = 0xFC; // lowercase u with umlaut
> char c = std::toupper(uuml);
> constexpr char cc = std::toupper(uuml);
> assert( c == cc );


With regard to Unicode:
* The Standard mentions Unicode and allows for Unicode escape
sequences (e.g. "\u00f1")
* The first 128 characters in Unicode (up to 0x7F) are ASCII
* The remaining characters up to 0xFF are ISO-8859-1 (aka Latin-1)

Therefore it makes sense that the Standard would provide inline
constexpr functions like:

    namespace std {
        namespace unicode {
            inline constexpr char32_t tolower(char32_t) { . . . }
        }
    }

Received on 2025-07-06 12:38:09