WCRTOMB(3)

๐Ÿ“ฆ version 15.1, in freebsd 14.5, freebsd 15.1

๐ŸŒธ WCRTOMB(3) ๐ŸŒธ

๐Ÿ’– NAME ๐Ÿ’–

okay so this is the Library Functions Manual page for wcrtomb, c16rtomb, c32rtomb โ€” convert a wide-character code to a character (restartable). literally the whole vibe ๐Ÿ’…

๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C Library (libc, -lc) โ€” that's the library, bestie ๐Ÿซถ

โœจ SYNOPSIS โœจ

#include <wchar.h>

size_t
wcrtomb(char * restrict s, wchar_t c, mbstate_t * restrict ps);

#include <uchar.h>

size_t
c16rtomb(char * restrict s, char16_t c, mbstate_t * restrict ps);

size_t
c32rtomb(char * restrict s, char32_t c, mbstate_t * restrict ps);

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so the tea โ˜•: wcrtomb(), c16rtomb() and c32rtomb() store a multibyte sequence representing the wide character c, including any necessary shift sequences, to the character array s, storing a maximum of MB_CUR_MAX bytes. literally the glow-up from wide char to multibyte โœจ

If s is NULL, these functions behave as if s pointed to an internal buffer and c was a null wide character (L'\0'). no cap, that's the rule.

The mbstate_t argument, ps, is used to keep track of the shift state. If it is NULL, these functions use an internal, static mbstate_t object, which is initialized to the initial conversion state at program startup. bestie, that static object is lowkey just always there.

As certain multibyte characters may only be represented by a series of 16-bit characters, the c16rtomb() may need to be invoked multiple times before a multibyte sequence is returned. so yeah, sometimes it's a multi-step situation ๐Ÿ’…

๐Ÿ”ฅ RETURN VALUES ๐Ÿ”ฅ

These functions return the length (in bytes) of the multibyte sequence needed to represent c, or (size_t)-1 if c is not a valid wide character code. that's the whole return story, fr fr ๐Ÿซถ

๐Ÿ’€ ERRORS ๐Ÿ’€

The wcrtomb(), c16rtomb() and c32rtomb() functions will fail if:

  • [EILSEQ] โ€” an invalid wide character code was specified.
  • [EINVAL] โ€” the conversion state is invalid.

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

๐ŸŒˆ STANDARDS ๐ŸŒˆ

The wcrtomb(), c16rtomb() and c32rtomb() functions conform to ISO/IEC 9899:2011 (โ€œISO C11โ€). periodt. ๐Ÿ‘‘


mwah ๐Ÿ’‹ this page is from Debian, dated May 21, 2013, and it's the WCRTOMB(3) page โ€” bye bestie, go convert some wide chars responsibly! ๐Ÿซถ๐Ÿ’…

๐Ÿ“ฆ where this page comes from