std::ctype:...:do_toupper(3)
πΈ NAME πΈ
okay so bestie, this is the page for std::ctype::toupper,std::ctype::do_toupper β the header up top says std::ctype:...:do_toupper(3), and it's from the C++ Standard Libary manual (yep, that's the spelling on the page, no cap π
). The NAME line is std::ctype::toupper,std::ctype::do_toupper β dash β std::ctype::toupper,std::ctype::do_toupper again, because the page said it twice and we're not erasing that. It's giving "let's uppercase some characters, but make it locale-aware" energy, and we're keeping every single deet. periodt.
β¨ Synopsis β¨
Defined in header <locale>
public:
(1)
CharT toupper( CharT c ) const;
public:
(2)
const CharT* toupper( CharT* beg, const CharT* end ) const;
protected:
(3)
virtual CharT do_toupper( CharT c ) const;
protected:
(4)
virtual const CharT* do_toupper( CharT* beg, const CharT* end )
const;
the vibe check on the numbered ones:
1,2)β Public member function, calls the protected virtual member functiondo_toupperof the most derived class.3)β Converts the charactercto upper case if an upper case form is defined by this locale.4)β For every character in the character array[beg, end), for which an upper case form exists, replaces the character with that upper case form.
π Parameters π
cβ character to convert.begβ pointer to the first character in an array of characters to convert.endβ one past the end pointer for the array of characters to convert.
π¦ Return value π¦
1,3)β upper case character orcif no upper case form is listed by this locale.2,4)βend.
π Notes π
Only 1:1 character mapping can be performed by this function, e.g. the uppercase form of 'Γ' is the two-character string "SS" (with some exceptions - see Β«Capital αΊΒ»), which cannot be obtained by do_toupper. highkey important if you were expecting magic multi-character glow-ups π.
π Example π
obsessed with this little demo, fr fr:
// Run this code
#include <iostream>
#include <locale>
void try_upper(const std::ctype<wchar_t>& f, wchar_t c)
{
wchar_t up = f.toupper(c);
if (up != c)
std::wcout << "Upper case form of \'" << c << "' is " << up << '\n';
else
std::wcout << '\'' << c << "' has no upper case form\n";
}
int main()
{
std::locale::global(std::locale("en_US.utf8"));
std::wcout.imbue(std::locale());
std::wcout << "In US English UTF-8 locale:\n";
auto& f = std::use_facet<std::ctype<wchar_t>>(std::locale());
try_upper(f, L's');
try_upper(f, L'ΕΏ');
try_upper(f, L'Ξ΄');
try_upper(f, L'ΓΆ');
try_upper(f, L'Γ');
std::wstring str = L"Hello, World!";
std::wcout << "Uppercase form of the string '" << str << "' is ";
f.toupper(&str[0], &str[0] + str.size());
std::wcout << '\'' << str << "'\n";
}
and the output is literally:
In US English UTF-8 locale:
Upper case form of 's' is S
Upper case form of 'ΕΏ' is S
Upper case form of 'Ξ΄' is Ξ
Upper case form of 'ΓΆ' is Γ
'Γ' has no upper case form
Uppercase form of the string 'Hello, World!' is 'HELLO, WORLD!'
π₯ See also π₯
tolowerβ invokesdo_tolower(public member function)toupperβ converts a character to uppercase (function)towupperβ converts a wide character to uppercase (function)
that's the whole page, bestie π«Ά β signing off from http://cppreference.com, date/version 2024.06.10, page std::ctype:...:do_toupper(3). mwah π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms