Skip to content

🈂️ Unicode Support

Feldwor edited this page Jul 22, 2021 · 14 revisions
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <locale.h>

int main()
{
    const wchar_t hmm[] = L"äö";

    setlocale(LC_ALL, "");
    wprintf(L"%ls\n", hmm);
    wprintf(L"%lc\n", hmm[0]);
    wprintf(L"%i\n", wcslen(hmm));

    return 0;
}

https://stackoverflow.com/questions/14083706/iterating-through-a-char-array-with-non-standard-chars/14083757#14083757

Emoji support

https://stackoverflow.com/questions/23915322/printing-a-smiley-using-c-in-netbeans

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <locale.h>
#include <wchar.h>
#include <time.h>
int main(void)
   {
   setlocale(LC_ALL, ".437");
   wchar_t * smiley = L"įšįėų☺";   
   wprintf(L"[%s]\n", smiley);

   return(0);
   }

Ways to set the code page in C


setlocale(LC_ALL, "");
setlocale(LC_ALL, ".65001");
char* res = setlocale(LC_ALL, ".UTF8");

Learning and Reference of C language. Public Domain.
Also available in CC0 or MIT License.

Clone this wiki locally