We help IT Professionals succeed at work.

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

9,613 Views
Last Modified: 2013-11-23
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)
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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;
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.