Sindbad~EG File Manager

Current Path : /home/beeson/public_html/WebMathXpert/Examples/
Upload File :
Current File : //home/beeson/public_html/WebMathXpert/Examples/UTF8Example2.c

#include <stdio.h>
#include <locale.h>
#include <wchar.h>
#include <stdlib.h>

int main() {
    setlocale(LC_CTYPE, "");
    const char *utf8String = "Hello, 你好, こんにちは";

    const wchar_t *wstr = NULL;
    size_t wlen = mbstowcs(NULL, utf8String, 0);
    wstr = malloc((wlen + 1) * sizeof(wchar_t));
    mbstowcs(wstr, utf8String, wlen);

    for (size_t i = 0; i < wlen; i++) {
        wprintf(L"%lc ", wstr[i]);
    }

    free(wstr);
    return 0;
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists