Exception with German Umlaut characters in TMemIniFile.Create

前端 未结 3 1948
栀梦
栀梦 2021-01-25 13:52

I have an .URL file which contains the following text which contains a German Umlaut character:

[InternetShortcut]
URL=http://edn.embarcadero.com/ar

3条回答
  •  广开言路
    2021-01-25 13:58

    It is not possible, in general, to auto-detect the encoding of a file from its contents.

    A clear demonstration of this is given by this article from Raymond Chen: The Notepad file encoding problem, redux. Raymond uses the example of a file containing these two bytes:

    D0 AE
    

    Raymond goes on to show that this is a well formed file with the following four encodings: ANSI 1252, UTF-8, UTF-16BE and UTF-16LE.

    The take home lesson here is that you have to know the encoding of your file. Either agree it by convention with whoever writes the file. Or enforce the presence of a BOM.

提交回复
热议问题