Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi TIniFile speichert manchmal UTF8 statt ANSI (https://www.delphipraxis.net/215307-tinifile-speichert-manchmal-utf8-statt-ansi.html)

Uwe Raabe 11. Jun 2024 14:57

AW: TIniFile speichert manchmal UTF8 statt ANSI
 
Das Verhalten von TIniFile bzw. der dahinter liegenden WritePrivateProfileString Funktion ist in der Tat schwer zu durchschauen.

Zum Einen wird Unicode geschrieben, wenn die Datei schon als Unicode Datei vorliegt, andernfalls ANSI:
https://learn.microsoft.com/en-us/wi...profilestringa
Zitat:

If the file was created using Unicode characters, the function writes Unicode characters to the file. Otherwise, the function writes ANSI characters.
Dazu kommt dann noch eine etwas versteckt liegende Windows-Option, die anstatt ANSI dann netterweise UTF8 schreibt:
https://en.wikipedia.org/wiki/Unicod...rosoft_Windows
Zitat:

In April 2018 (or possibly November 2017[13]), with insider build 17035 (nominal build 17134) for Windows 10, a "Beta: Use Unicode UTF-8 for worldwide language support" checkbox appeared for setting the locale code page to UTF-8.[a] This allows for calling "narrow" functions, including fopen and SetWindowTextA, with UTF-8 strings. However this is a system-wide setting and a program cannot assume it is set.
https://learn.microsoft.com/en-us/wi...utf8-code-page
Zitat:

-A vs. -W APIs
Win32 APIs often support both -A and -W variants.

-A variants recognize the ANSI code page configured on the system and support char*, while -W variants operate in UTF-16 and support WCHAR.

Until recently, Windows has emphasized "Unicode" -W variants over -A APIs. However, recent releases have used the ANSI code page and -A APIs as a means to introduce UTF-8 support to apps. If the ANSI code page is configured for UTF-8, then -A APIs typically operate in UTF-8. This model has the benefit of supporting existing code built with -A APIs without any code changes.

Nur so am Rande:
https://learn.microsoft.com/en-us/wi...profilestringa
Zitat:

Note This function is provided only for compatibility with 16-bit versions of Windows. Applications should store initialization information in the registry.

haentschman 12. Jun 2024 08:16

AW: TIniFile speichert manchmal UTF8 statt ANSI
 
Danke für die Informationen...:wink:

Ich habe mich entschieden für TMemIniFile mit TEncoding.UTF8. :wink:
Wenn eine ANSI Datei mit enthaltenen Umlauten geladen werden soll kommt "Keine Zuordnung für Unicode-Zeichen in der Multibyte-Zielcodeseite vorhanden". Dann müssen sie bei mir anrufen und ich ändere die Datei manuell auf UTF8-BOM. :thumb: Das ist einfacher als das auszuprogrammieren...

Frickler 13. Jun 2024 17:49

AW: TIniFile speichert manchmal UTF8 statt ANSI
 
Zitat:

Zitat von Uwe Raabe (Beitrag 1537635)
Dazu kommt dann noch eine etwas versteckt liegende Windows-Option, die anstatt ANSI dann netterweise UTF8 schreibt:
https://en.wikipedia.org/wiki/Unicod...rosoft_Windows
Zitat:

In April 2018 (or possibly November 2017[13]), with insider build 17035 (nominal build 17134) for Windows 10, a "Beta: Use Unicode UTF-8 for worldwide language support" checkbox appeared for setting the locale code page to UTF-8.[a] This allows for calling "narrow" functions, including fopen and SetWindowTextA, with UTF-8 strings. However this is a system-wide setting and a program cannot assume it is set.

Manche OEMs aktivieren diese Option, ohne das zu kommunizieren. Wir hatten das bei Kunden-PCs von HP und Dell, die mit Windows 10 Pro ausgeliefert wurden. Datenbankeinträge waren plötzlich unlesbar, aber nur, wenn sie auf bestimmten PCs vorgenommen wurden. War ein Heidenspaß, die Fehlerursache zu finden...

himitsu 13. Jun 2024 20:06

AW: TIniFile speichert manchmal UTF8 statt ANSI
 
Zitat:

Spaß
Party :party:


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:42 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz