Search code examples
delphiencodingdelphi-2006

Delphi - get encoding for a given file


I have read this question which I thought would give me what I was after:

How Can I Best Guess the Encoding when the BOM (Byte Order Mark) is Missing?

I would like to know if there is another way to get the file encoding, without using Mozilla's i18n component in D2006? I can not use other 3d party components.

I have read the all the answers from original question, and I can not use the interface provided because the client doesn't accept the deployment of that dll:

Some of the links provided in the original question are dead, and none address my problem, which is:
How to get the file encoding without using 3rd party components?


Solution

  • I would look for a BOM first and if one is not found call IsTextUnicode. But beware that no method is foolproof.