Namespaces
Variants
Views
Actions

Talk:cpp/string/byte/isdigit

From cppreference.com
< Talk:cpp‎ | string/byte
Revision as of 04:27, 2 January 2023 by A9g (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

[edit] "some implementations (e.g. Microsoft in 1252 codepage) may classify additional single-byte characters as digits"

Where is the evidence that this is the case? Which characters?

I would expect this only from the locale version of isdigit.

There is a comment referring to a note in the C standard which states that it is not affected by the locale.

Simon (talk) 03:01, 31 March 2021 (PDT)

Run this code in visual studio:
#include <cctype>
#include <clocale>
#include <iostream>
 
int main()
{
    std::setlocale(LC_ALL, ".1252");
 
    for (unsigned c{}; c < 0x100; ++c)
        if (std::isdigit(c))
            std::cout << c << ": " << char(c) << '\n';
}

Output:

48: 0
49: 1
50: 2
51: 3
52: 4
53: 5
54: 6
55: 7
56: 8
57: 9
178: ²
179: ³
185: ¹

[edit] Using plain char is work in GCC and clang

I apologize for my lack of knowledge on the matter.

A9g (talk) 02:22, 12 December 2022 (PST)

A9g (talk) 04:27, 2 January 2023 (PST)