skip to Main Content

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.

  1. Os Name: Windows 10
  2. Programming Language: C
  3. 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


  1. setlocale(LC_CTYPE, "en_US.UTF-8")
    setlocale(LC_CTYPE, "turkish")
    setlocale(LC_CTYPE, "iso-8859-9")

    you can try these code.

    Login or Signup to reply.
  2. Vs Code >Preferences>Settings

    Then;

    Search

    Files Encoding:

    You can choose ISO-8859-9

    And setlocale(LC_ALL="Turkish")

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search