Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,
I just want to read read unicode text file in normal c.
Following code is not working for same,

include<stdio.h>

C++
int main()
{
        FILE *ptr_file;
        char buf[1000];

        ptr_file =fopen("input.txt","r");
        if (!ptr_file)
            return 1;

        while (fgets(buf,1000, ptr_file)!=NULL)
            printf("%s",buf);

    fclose(ptr_file);
        return 0;
}
Posted

use wchar_t instead of char for your buffer..
 
Share this answer
 
See fgetws()[^] for reading Unicode. You could also take a look at my tip, Handling simple text files in C/C++[^], which shows how to read ANSI or Unicode, and convert between the two.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900