C examples for uchar.h:mbrtoc32
function
<cuchar>
Convert multibyte sequence to 32-bit character
size_t mbrtoc32 ( char32_t * pc32, const char * pmb, size_t max, mbstate_t * ps);
Parameter | Description |
---|---|
pc32 | Pointer to an object of type char32_t. |
pmb | Pointer to the first byte of a multibyte character. |
max | Maximum number of bytes to read from pmb. |
ps | a mbstate_t object that defines a conversion state. |
#pragma warning(disable:4996)//from w w w .j av a2 s . c om #define _CRT_SECURE_NO_WARNINGS #include <wchar.h> #include <uchar.h> #include <stdio.h> #include <stdlib.h> int main() { char32_t* pt = U"this is a test\u00e9"; char buffer[123]; size_t length; mbstate_t mbs; mbrlen(NULL, 0, &mbs); while (*pt) { length = mbrtoc32(pt, buffer, 2, &mbs); if ((length == 0) || (length>MB_CUR_MAX)) break; for (int i = 0; i<length; ++i) putchar(buffer[i]); ++pt; } return 0; }