I don't understand why my question was closed? The problem is not in the encoding. The problem is in the integrated terminal of vs code.
I am working with MSVC compiler in VS Code. I set the integrated terminal to powershell 7. The code page is UTF-8, that is 65001. There is no problem with functions like printf and puts, UTF-8 characters can be printed to the screen, but when I try to read utf-8 to a buffer with fgets and print the buffer to the screen, I cannot get the desired result. Here is the code:
#include <locale.h>
#include <stdio.h>
int main(){
char *charset = setlocale(LC_ALL, ".UTF-8");
char buffer[64]; puts("Enter something...");
fgets(buffer, sizeof buffer, stdin);
printf("charset: %s\ninput: %s\n", charset, buffer); }
Here is the output:
Enter something...
ĞÜŞİÖÇ
charset: Turkish_Turkey.utf8
input:
When I run the same program with Powershell 7 it works fine. But it doesn't work properly in integrated terminal of vs code.