How to handle UTF-8 and ANSI conversion before Delphi 2009?

Please_Dont_Bully_Me_SO_Lords picture Please_Dont_Bully_Me_SO_Lords · Mar 1, 2013 · Viewed 8.6k times · Source

In Delphi 2009 we have:

RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName,TEncoding.UTF8);
RichEdit1.Lines.SaveToFile(OpenDialog2.FileName,TEncoding.Unicode);    

How do I do that on Delphi 2006 if I do not have TEconding yet?

Is there someway to transport that newer library back there? or is there a solution hidden in the Web?

Answer

Andreas Rejbrand picture Andreas Rejbrand · Mar 1, 2013

I believe that UTF8Encode and UTF8Decode were present even before Delphi 2009. So you can decode/encode byte strings manually. (I have done that myself.)