I read a file with 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());
And it reads perfectly (this is shown in Editbox when the program starts):
Edit1->Text=C;
Result ===> "3021";"δΊ";"7";"γ’ γ’γ·γ’ γ€.γ T1 γ γ€γ γ€γ"
The thing is, when I want to write this to 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 to write the result (the one that I see in the running program) in a file?
I am using C language on CodeGear C ++ Builder
Resolved
thanks to Christophe and nobility for helping
I changed this line
fwrite(Edit8->Text.c_str(),strlen(Edit8->Text.c_str()),1,FileOUT);
to this, and it worked. Thanks
fwrite(UTF8Encode(Edit8->Text).c_str(),UTF8Encode(Edit8->Text).Length(),1,FileOUT);