Today I found some old source code. Someone wanted to write a file in the old OEM codepage. Therefore he wrote a small function that encapsulates the Windows API CharToOem function.

After that he added the OEM string to a TStringList and saved the TStringList to a file.

I’m surprised that this code does work. Since Delphi 2010 strings are Unicode strings. This means that the OEM string is stored in a Unicode string variable.

Instead, I think is is much easier to use the wonderful TEncoding class.

This entry was posted in Tips and Tricks and tagged . Bookmark the permalink.