C examples for uchar.h:c32rtomb
function
<cuchar>
Convert 32-bit character to multibyte sequence
size_t c32rtomb ( char * pmb, char32_t c32, mbstate_t * ps );
Parameter | Description |
---|---|
pmb | an array to hold a multibyte sequence. |
c32 | 32-bit character of type char32_t. |
ps | Pointer to a mbstate_t object that defines a conversion state. |
On success, return the size of the multibyte sequence written at pmb in bytes.
If there is no character correspondence, the function returns -1 and sets errno to EILSEQ.
If pmb is a null pointer, the function stores no bytes at pmb, and returns zero.
#pragma warning(disable:4996)// w w w . j a v a2 s . com #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 = c32rtomb(buffer,*pt,&mbs); if ((length==0)||(length>MB_CUR_MAX)) break; for (int i=0;i<length;++i) putchar (buffer[i]); ++pt; } return 0; }