I am trying to read a text file in Unicode and write data to a text file. Here is the code. Reading works great. I can tell because it shows a false character on the console, but the output text file is empty. Any help would be appreciated!
int main() { wchar_t *filename=L"normal.txt"; FILE *infile; infile=_wfopen(filename,L"r"); wchar_t b[2]; fwscanf(infile,L"%ls",b); wprintf(L"The string read was :%ls\n",b);//Read a character from the file FILE *outfile; wchar_t *filetwo = L"one.txt"; outfile=_wfopen(filetwo,L"w, ccs=UTF-16LE"); fwprintf(outfile,L"%ls",b); fclose(outfile); getch(); return 0; }
In addition, I need to deal with Devanagari scripts in particular. How many bytes do they take? If it's 4, you'll learn how to handle those using wchar_t because it has a width of only 2 bytes.
source share