i am using Delphi 7, I wrote a program that get some information from user, combines info from several editboxes and memos and other input components in a memo. How can I save this Memo as a UTF 8 text file? I received some files from last program's users without a solution for utf problem and now, when i open the output file i see ???? (as you know!) instead of different language characters, these are not recoverable, are they?
Like this:
const
UTF8BOM: array[0..2] of Byte = ($EF, $BB, $BF);
var
UTF8Str: UTF8String;
FS: TFileStream;
begin
UTF8Str := UTF8Encode(Memo1.Text);
FS := TFileStream.Create('C:\path to\file.txt', fmCreate);
try
FS.WriteBuffer(UTF8BOM[0], SizeOf(UTF8BOM));
FS.WriteBuffer(PAnsiChar(UTF8Str)^, Length(UTF8Str));
finally
FS.Free;
end;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With