std::c8rtomb(3)
π
std::c8rtomb(3) β C++ Standard Libary π
hey bestie π welcome to the std::c8rtomb(3) page, aka the one where a UTF-8 code point gets converted into a narrow multibyte character representation. it's giving very specific, very C++20, and we're keeping every tiny detail because that's the vibe.
π NAME π
std::c8rtomb β std::c8rtomb
πΈ Synopsis πΈ
Defined in header <cuchar>
std::size_t c8rtomb( char* s, char8_t c8, std::mbstate_t* ps );
β¨ (since C++20) β¨
okay so this function converts a single code point from UTF-8 to a narrow multibyte character representation. here's the whole tea, branch by branch:
- If
sis not a null pointer andc8is the last code unit in a valid UTF-8 encoding of a code point, the function determines the number of bytes necessary to store the multibyte character representation of that code point (including any shift sequences, and taking into account the current multibyte conversion state*ps), and stores the multibyte character representation in the character array whose first element is pointed to bys, updating*psas necessary. At mostMB_CUR_MAXbytes can be written by this function. - If
c8is not the final UTF-8 code unit in a representation of a code point, the function does not write to the array pointed to bys, only*psis updated. - If
sis a null pointer, the call is equivalent tostd::c8rtomb(buf, u8'\0', ps)for some internal bufferbuf. - If
c8is the null characteru8'\0', a null byte is stored, preceded by any shift sequence necessary to restore the initial shift state and the conversion state parameter*psis updated to represent the initial shift state. - The multibyte encoding used by this function is specified by the currently active C locale.
π Parameters π
sβ pointer to narrow character array where the multibyte character will be storedc8β the UTF-8 code unit to convertpsβ pointer to the conversion state object used when interpreting the multibyte string
π«Ά Return value π«Ά
The return value is the number of bytes stored in the array object (including any shift sequences). This may be zero when c8 is not the final code unit in the UTF-8 representation of a code point.
If c8 is invalid (does not contribute to a sequence of char8_t corresponding to a valid multibyte character), the value of the macro EILSEQ is stored in errno, static_cast<std::size_t>(-1) is returned, and the conversion state is unspecified. bestie, that's unspecified β do not make assumptions, periodt.
π¦ Notes π¦
Calls to c8rtomb with a null pointer argument for s may introduce a data race with other calls to c8rtomb with a null pointer argument for s. so like⦠be careful with that null-s situation, iykyk.
π Example π
This section is incomplete.
Reason: no example.
π See also π
mbrtoc8converts a narrow multibyte character to UTF-8 encoding(C++20)(function)- C documentation for
c8rtomb
ποΈ Category ποΈ
Todo no example
later, bestie π«Ά this page is sourced from http://cppreference.com, with version/date 2024.06.10, and yes it's the std::c8rtomb(3) page. slay and read your manpages responsibly π
β¨
π¦ 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