Link to home
Create AccountLog in
Avatar of Povilas
Povilas

asked on

How to load/save text file to/from MEMO component in UTF-8 format?

I need to load simple text file to memo1 component and it is done easily by .Lines.LoadFromFile. Same with text save to file from memo1- .Lines.SaveToFile

How can I add UTF-8 text format support for this operation? (now it depends on system configuration)

by the way, I need to do some line string operations in that memo1 component (so I need to do string operations in UTF-8 also)
ASKER CERTIFIED SOLUTION
Avatar of radu84
radu84

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Povilas
Povilas

ASKER

Here is my solution for this (temporary, waiting for native Delphi UTF-8 support):

S := UTF8Encode(Memo.Text);
 AssignFile(F, );
  try
    Rewrite(F);
    Write(F,#$EF+#$BB+#$BF); //UTF8
    Write(F, S);
    CloseFile(F);
   except
   end;