In C Programming; I cannot read files from a directory with Turkish characters, but if I change the name of the folder containing Turkish characters, I can read them.
- Os Name: Windows 10
- Programming Language: C
- IDE: Visual Studio Code
I have folder named Ülke.
I cannot read files from this directory.
DIR *dr = opendir("C:/Users/softeng/tutorials/comp/Ülke/");
but When I rename this folder to Ulke, I can read it.
DIR *dr = opendir("C:/Users/softeng/tutorials/comp/Ulke/");
All Code;
#include <stdio.h>
#include <dirent.h>
#include <locale.h>
int main(void)
{
setlocale(LC_ALL, "Turkish");
struct dirent *de;
DIR *dr = opendir("C:/Users/softeng/tutorials/comp/Ülke/");
if (dr == NULL) {
printf("Could not open current directory" );
return 0;
}
while ((de = readdir(dr)) != NULL)
printf("%sn", de->d_name);
closedir(dr);
return 0;
}
How can i solve it.
2
Answers
setlocale(LC_CTYPE, "en_US.UTF-8")
setlocale(LC_CTYPE, "turkish")
setlocale(LC_CTYPE, "iso-8859-9")
you can try these code.
Vs Code >Preferences>Settings
Then;
Search
Files Encoding:
You can choose ISO-8859-9
And setlocale(LC_ALL="Turkish")