This shows you the differences between two versions of the page.
c:wchar.h:btowc [2013/01/22 22:02] |
c:wchar.h:btowc [2024/02/16 01:05] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{keywords>wiki library source code example reference}} | ||
+ | ===== btowc ===== | ||
+ | <code c> | ||
+ | #include <wchar.h> | ||
+ | wint_t btowc(int); | ||
+ | </code> | ||
+ | |||
+ | ==== Description ==== | ||
+ | convert a byte to wide character | ||
+ | btowc returns the wide two byte character "wchar_t" converted from the single byte "string" character (char). | ||
+ | |||
+ | |||
+ | === return value === | ||
+ | If the argument is not a valid multibyte sequence of length 1 btowc returns WEOF.\\ | ||
+ | output is affected by the current LC_TYPE locale.\\ | ||
+ | |||
+ | ===== btowc C Sourcecode Example ===== | ||
+ | <code c> | ||
+ | /* | ||
+ | * btowc example code | ||
+ | * http://code-reference.com/c/wchar.h/btowc | ||
+ | */ | ||
+ | |||
+ | #include <stdio.h> | ||
+ | #include <wchar.h> | ||
+ | |||
+ | int main( void ) { | ||
+ | |||
+ | char string[] = "btowc \x65xampl\x65"; | ||
+ | int i; | ||
+ | |||
+ | for ( i = 0; i < 13; ++i) { | ||
+ | printf("%c %c\n", string[i], (wchar_t)btowc(string[i]) ); | ||
+ | } | ||
+ | return 0; | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | ==== output ==== | ||
+ | b b | ||
+ | t t | ||
+ | o o | ||
+ | w w | ||
+ | c c | ||
+ | |||
+ | e e | ||
+ | x x | ||
+ | a a | ||
+ | m m | ||
+ | p p | ||
+ | l l | ||
+ | e e | ||
+ | |||
+ |