Files
RedBear-OS/tests/wchar/mbsrtowcs.c
T
Jeremy Soller 950b4526c7 - Disable output of empty header files
- Remove incorrect header styles
- Use export.replace where header style was previously needed
- Check compilation of tests using system gcc
2018-11-26 21:35:02 -07:00

25 lines
577 B
C

#include <stdio.h>
#include <string.h>
#include <wchar.h>
void print_as_wide(const char* mbstr)
{
mbstate_t state;
memset(&state, 0, sizeof state);
size_t len = 1 + mbsrtowcs(NULL, &mbstr, 0, &state);
wchar_t wstr[len];
mbsrtowcs(&wstr[0], &mbstr, len, &state);
//Should be 5
printf("The length, including '\\0': %li \n",len);
//missing wprintf to print this wide string
//wprintf(L"The wide string: %ls \n", &wstr[0]);
}
int main()
{
const char* mbstr = u8"z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌"
print_as_wide(mbstr);
}