I read a file that has utf8 characters like this:
FILE *FileIN,*FileOUT;
FileIN=fopen("filename","r");
char string[600];
WideChar C[600],S[100];
fgets(string,600,FileIN);
wcscpy(C,UTF8Decode(string).c_bstr()); // widechar copy
And it reads it perfectly (this is shown in the Editbox when running the program):
Edit1->Text=C;
Result ===> "3021";"亜";"7";"ア アシア つ.ぐ T1 や つぎ つぐ"
The thing is that when I want to write this on a file:
FileOUT=fopen("txt.txt","w");
fwrite(Edit8->Text.c_str(),strlen(Edit8->Text.c_str()),1,FileOUT);
Result ===> "3021";"?";"7";"? ??? ?.? T1 ? ?? ??"
The question is, how do I write the result (the one i can see in the program running) in a file?
I use C language on CodeGear C++Builder
Resolved thanks to Christoph and nobugz for the help
I changed this line
fwrite(Edit8->Text.c_str(),strlen(Edit8->Text.c_str()),1,FileOUT);
to this one and it worked. Thanks
fwrite(UTF8Encode(Edit8->Text).c_str(),UTF8Encode(Edit8->Text).Length(),1,FileOUT);