Home > database >  Changing utf encoding in visual studio (C )
Changing utf encoding in visual studio (C )

Time:11-09

I am making a C console program that I would like be able to use some characters from my native language (like š, č, ž, ų, etc.). They all exist in UTF-16 encoding.

Is it safe to change my visual studio utf encoding to mentioned UTF-16 and how do I do it properly?

CodePudding user response:

I suggest you to use the following code, it can achieve your needs

#include <fcntl.h>
#include <io.h>
#include <stdio.h>

int main() {
  _setmode(_fileno(stdout), _O_WTEXT);
  
  wprintf(L"ščžų");
  
}

enter image description here

  • Related