std::iswdigit(3)

📦 version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

💖 std::iswdigit(3) — C++ Standard Libary 💖

okay so bestie, this is the std::iswdigit(3) page from the C++ Standard Libary manual (yes, that's the manual name, typo and all 💀). It's literally the C++ standard library wide-character digit check, and we're gonna read it together like a group chat. No cap.


💖 NAME 💖

std::iswdigit — std::iswdigit. That's the name. Iconic, minimal, no notes. 💅

✨ Synopsis ✨

Defined in header <cwctype>:

int iswdigit( wint_t ch );

Checks if the given wide character corresponds (if narrowed) to one of the ten decimal digit characters 0123456789.

🚨 okay important: if the value of ch is neither representable as a wchar_t nor equal to the value of the macro WEOF, the behavior is undefined. Like, do not test that on purpose, bestie. 😭

🎀 Parameters 🎀

  • ch — wide character.

That's the whole parameter list. Slay. ✨

🦋 Return value 🦋

Non-zero value if the wide character is a numeric character, zero otherwise.

🌸 Notes 🌸

std::iswdigit and std::iswxdigit are the only standard wide character classification functions that are not affected by the currently installed C locale. That's the note. Lowkey iconic. 👑

💅 Example 💅

Some locales offer additional character classes that detect non-ASCII digits.

There's a // Run this code link right before the example. The code itself is this exact vibe:

#include <clocale>
#include <cwctype>
#include <iostream>

void test(wchar_t a3, wchar_t u3, wchar_t j3)
{
    std::wcout << std::boolalpha
               << "\t   '" << a3 << "'   '" << u3 << "'  '" << j3  << "'\n"
               << "iswdigit: "
               << (bool)std::iswdigit(a3) << "  "
               << (bool)std::iswdigit(u3) << " "
               << (bool)std::iswdigit(j3) << '\n'
               << "jdigit:   "
               << (bool)std::iswctype(a3, std::wctype("jdigit")) << ' '
               << (bool)std::iswctype(u3, std::wctype("jdigit")) << ' '
               << (bool)std::iswctype(j3, std::wctype("jdigit")) << '\n';
}

int main()
{
    wchar_t a3 = L'3';  // the ASCII digit 3
    wchar_t u3 = L'三'; // the CJK numeral 3
    wchar_t j3 = L'3'; // the full-width digit 3

    std::setlocale(LC_ALL, "en_US.utf8");
    std::wcout << "In American locale:\n";
    test(a3, u3, j3);

    std::wcout << "\nIn Japanese locale:\n";
    std::setlocale(LC_ALL, "ja_JP.utf8");
    test(a3, u3, j3);
}

🔥 Possible output 🔥

In American locale:
           '3'   '三'  '3'
iswdigit: true  false false
jdigit:   false false false

In Japanese locale:
           '3'   '三'  '3'
iswdigit: true  false false
jdigit:   false false true

⭐ See also ⭐

  • isdigit(std::locale) — checks if a character is classified as a digit by a locale (function template).
  • isdigit — checks if a character is a digit (function).
  • C documentation for iswdigit.

🧮 ASCII values chart (the whole big classification vibe) 🧮

The chart's column names, as they show up in the original, are: ASCII values, characters, iscntrl, isprint, isspace, isblank, isgraph, ispunct, isalnum, isalpha, isupper, islower, isdigit, isxdigit, decimal, hexadecimal, octal, iswcntrl, iswprint, iswspace, iswblank, iswgraph, iswpunct, iswalnum, iswalpha, iswupper, iswlower, iswdigit, iswxdigit. 🫶

Here are the rows, with every value kept:

  • decimal 0–8 · hexadecimal \x0–\x8 · octal \0–\10 · characters control codes (NUL, etc.) · flags: iscntrl=≠0, isprint=0, isspace=0, isblank=0, isgraph=0, ispunct=0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.
  • decimal 9 · hexadecimal \x9 · octal \11 · characters tab (\t) · flags: iscntrl=≠0, isprint=0, isspace=≠0, isblank=≠0, isgraph=0, ispunct=0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.
  • decimal 10–13 · hexadecimal \xA–\xD · octal \12–\15 · characters whitespaces (\n, \v, \f, \r) · flags: iscntrl=≠0, isprint=0, isspace=≠0, isblank=0, isgraph=0, ispunct=0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.
  • decimal 14–31 · hexadecimal \xE–\x1F · octal \16–\37 · characters control codes · flags: iscntrl=≠0, isprint=0, isspace=0, isblank=0, isgraph=0, ispunct=0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.
  • decimal 32 · hexadecimal \x20 · octal \40 · characters space · flags: iscntrl=0, isprint=≠0, isspace=≠0, isblank=≠0, isgraph=0, ispunct=0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.
  • decimal 33–47 · hexadecimal \x21–\x2F · octal \41–\57 · characters !"#$%&'()*+,-./ · flags: iscntrl=0, isprint=≠0, isspace=0, isblank=0, isgraph=≠0, ispunct=≠0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.
  • decimal 48–57 · hexadecimal \x30–\x39 · octal \60–\71 · characters 0123456789 · flags: iscntrl=0, isprint=≠0, isspace=0, isblank=0, isgraph=≠0, ispunct=0, isalnum=≠0, isalpha=0, isupper=0, islower=0, isdigit=≠0, isxdigit=≠0.
  • decimal 58–64 · hexadecimal \x3A–\x40 · octal \72–\100 · characters :;<=>?@ · flags: iscntrl=0, isprint=≠0, isspace=0, isblank=0, isgraph=≠0, ispunct=≠0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.
  • decimal 65–70 · hexadecimal \x41–\x46 · octal \101–\106 · characters ABCDEF · flags: iscntrl=0, isprint=≠0, isspace=0, isblank=0, isgraph=≠0, ispunct=0, isalnum=≠0, isalpha=≠0, isupper=≠0, islower=0, isdigit=0, isxdigit=≠0.
  • decimal 71–90 · hexadecimal \x47–\x5A · octal \107–\132 · characters GHIJKLMNOPQRSTUVWXYZ · flags: iscntrl=0, isprint=≠0, isspace=0, isblank=0, isgraph=≠0, ispunct=0, isalnum=≠0, isalpha=≠0, isupper=≠0, islower=0, isdigit=0, isxdigit=0.
  • decimal 91–96 · hexadecimal \x5B–\x60 · octal \133–\140 · characters [\]^_ plus a literal ` · flags: iscntrl=0, isprint=≠0, isspace=0, isblank=0, isgraph=≠0, ispunct=≠0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.
  • decimal 97–102 · hexadecimal \x61–\x66 · octal \141–\146 · characters abcdef · flags: iscntrl=0, isprint=≠0, isspace=0, isblank=0, isgraph=≠0, ispunct=0, isalnum=≠0, isalpha=≠0, isupper=0, islower=≠0, isdigit=0, isxdigit=≠0.
  • decimal 103–122 · hexadecimal \x67–\x7A · octal \147–\172 · characters ghijklmnopqrstuvwxyz · flags: iscntrl=0, isprint=≠0, isspace=0, isblank=0, isgraph=≠0, ispunct=0, isalnum=≠0, isalpha=≠0, isupper=0, islower=≠0, isdigit=0, isxdigit=0.
  • decimal 123–126 · hexadecimal \x7B–\x7E · octal \172–\176 · characters {|}~ · flags: iscntrl=0, isprint=≠0, isspace=0, isblank=0, isgraph=≠0, ispunct=≠0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.
  • decimal 127 · hexadecimal \x7F · octal \177 · characters backspace character (DEL) · flags: iscntrl=≠0, isprint=0, isspace=0, isblank=0, isgraph=0, ispunct=0, isalnum=0, isalpha=0, isupper=0, islower=0, isdigit=0, isxdigit=0.

This page came from http://cppreference.com, dated 2024.06.10, and it's the std::iswdigit(3) page. Byeee bestie, stay classifying 💖✨

📦 where this page comes from