tags:

views:

45

answers:

1

Hi, I've a file that was written on windows with encoding WINDOWS-1256, and I need to write a C program that reads bytes from this file and write them back to a new file with UTF-8 encoding.

How to read a file with a specific encoding in C ??

+4  A: 

Other than text mode and binary mode, there is no way to directly read specific encodings with C with standard API.

You would open the file as binary and read it in. Then you can use a library like libiconv to do the encoding / decoding of specific formats.

Brian R. Bondy