Name

btowc, wctob
- convert single byte to wide character

Library

libc.lib

Synopsis

  #include <wchar.h>
  wint_t btowc (int c);
  int wctob (wint_t c);

Return values

btowc function returns the wide character converted from the single byte c
.If c is EOF or not a valid multibyte sequence of length 1, it returns WEOF.


Detailed description

The btowc function converts a single-byte character into a corresponding wide character. If the character is EOF or not valid in the initial shift state, btowc returns WEOF.

The wctob function converts a wide character into a corresponding single-byte character. If the wide character is WEOF or not able to be represented as a single byte in the initial shift state, wctob returns WEOF.

The behavior of the btowc and wctob is affected by LC_CTYPE category of the current locale.


Examples

#include <wchar.h>
/* Illustrates how to use btowc API */
wint_t example_btowc(int c)
{
 wint_t wc;
 /* converting single byte to wide-character */
 wc = btowc(c);
 /* return the character that was converted */
return (wc);
}

         

#include <wchar.h>
/* Illustrates how to use wctob API */
int example_wctob(void)
{
 wint_t wc = L’a’;
 int c;
  
 /* represent a wide-char in a single byte*/
 c = wctob(wc);
 /* return the single byte */
 return(c);
}

         


Limitations

The current implementation of btowc and wctob is not affected by the LC_CTYPE category of the current locale. It works only for UTF8 character set.

See also

mbrtowc, wcrtomb
The btowc and wctob functions conform to -p1003.1-2001.
The btowc and wctob functions first appeared in 5.0.

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top