BTOWC(3POSIX)

πŸ’– BTOWC β€” single byte to wide character conversion πŸ’–

okay bestie, welcome to the POSIX Programmer's Manual entry for btowc, aka the little glow-up station where a sad lonely byte gets to become a wide character. πŸ¦‹

PROLOG β€” quick disclaimer before we get into it:

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

so like, check your local Linux page too, because Linux might be doing its own thing, or the whole thing might not even exist on your system. no cap. 😭


✨ NAME ✨

btowc β€” single byte to wide character conversion

it's giving glow-up energy, honestly.


🌸 SYNOPSIS 🌸

#include <stdio.h>
#include <wchar.h>

wint_t btowc(int c);

two headers, one function, one int going in, one wint_t coming out. periodt. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so the functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1‐2017 defers to the ISO C standard.

The btowc() function shall determine whether c constitutes a valid (one-byte) character in the initial shift state.

The behavior of this function shall be affected by the LC_CTYPE category of the current locale.

that's it, that's the whole job. it looks at your byte and is like "are you valid in the initial shift state or not, bestie?" 🧚


πŸ”₯ RETURN VALUE πŸ”₯

The btowc() function shall return WEOF if c has the value EOF or if (unsigned char) c does not constitute a valid (one-byte) character in the initial shift state. Otherwise, it shall return the wide-character representation of that character.

In the POSIX locale, btowc() shall not return WEOF if c has a value in the range 0 to 255 inclusive.

so like, WEOF means "nope, not valid", and anything else is the actual wide-char version. and in the POSIX locale specifically, every value from 0 to 255 is a yes. iconic. πŸ‘‘


πŸ’€ ERRORS πŸ’€

No errors are defined.

not a single one. zero. none. she simply doesn't do errors. πŸ™ˆ

The following sections are informative.


🌈 EXAMPLES 🌈

None.

(no examples, sorry bestie, we're rawdogging the spec today)


🫢 APPLICATION USAGE 🫢

None.


πŸ“ RATIONALE πŸ“

None.


⭐ FUTURE DIRECTIONS ⭐

None.


πŸ‘‘ SEE ALSO πŸ‘‘

  • wctob()

The Base Definitions volume of POSIX.1‐2017, <stdio.h>, <wchar.h>

(wctob() is literally the reverse glow-up btw, iykyk πŸ’œ)


Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page bestie!! this one came to you courtesy of IEEE/The Open Group, dated 2017, and it lives under the name BTOWC(3POSIX) in the POSIX Programmer's Manual. mwah, go convert some bytes. πŸ’–βœ¨πŸŽ€