Are you PAS files / units showing crazy characters in Delphi RAD Studio??

Here’s a weird thing that happened… a client from India, downloaded a project from GitHub. All good. The units had Unicode characters (Chinese, I think). When they opened it up in Delphi, they saw garbled text instead of the Unicode chars.

I thought it was probably because the client was using an older version of Delphi.

So I called for the unit and opened it on 10.4… and the effect was still the same… garbled chars. Then I took the same unit and opened it in Notepad++, it displayed fine. Somehow, Notepad++ figured it was UTF-8.

I, then, used Notepad++ to convert the file to UTF-8 , saved it… and reopened it in Delphi and all was good.

The customer is happy because they know how to fix it now!

My guess is that the Delphi IDE requires BOM info to be present in the file to understand how to display the characters else, it defaults to ANSI.

Update : It seems Marco Cantu had blogged about the issue 2 years back here… https://blog.marcocantu.com/blog/2018-october-delphi-utf8-no-bom.html

Leave a Reply

Your email address will not be published. Required fields are marked *