Name

btowc

Synopsis

Converts a byte character into a wide character

#include <stdio.h>
#include <wchar.h>
wint_tbtowc( int c );

The btowc() function returns the corresponding wide character for its byte character argument, if possible. A return value of WEOF indicates that the argument’s value is EOF, or that the argument does not represent a valid byte character representation in the initial shift state of a multibyte stream.

Example

/* Build a table of wide characters for the first 128 byte values */
wchar_t low_table[128];

for ( int i = 0; i < 128 ; i++ )
  low_table[ i ] = (wchar_t)btowc( i );

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.