AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi TIniFile speichert manchmal UTF8 statt ANSI
Thema durchsuchen
Ansicht
Themen-Optionen

TIniFile speichert manchmal UTF8 statt ANSI

Ein Thema von haentschman · begonnen am 11. Jun 2024 · letzter Beitrag vom 13. Jun 2024
Antwort Antwort
Seite 2 von 2     12   
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.207 Beiträge
 
Delphi 12 Athens
 
#11

AW: TIniFile speichert manchmal UTF8 statt ANSI

  Alt 11. Jun 2024, 14:57
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.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
Benutzerbild von haentschman
haentschman

Registriert seit: 24. Okt 2006
Ort: Seifhennersdorf / Sachsen
5.343 Beiträge
 
Delphi 12 Athens
 
#12

AW: TIniFile speichert manchmal UTF8 statt ANSI

  Alt 12. Jun 2024, 08:16
Danke für die Informationen...

Ich habe mich entschieden für TMemIniFile mit TEncoding.UTF8.
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. Das ist einfacher als das auszuprogrammieren...

Geändert von haentschman (12. Jun 2024 um 08:23 Uhr)
  Mit Zitat antworten Zitat
Frickler

Registriert seit: 6. Mär 2007
Ort: Osnabrück
569 Beiträge
 
Delphi XE6 Enterprise
 
#13

AW: TIniFile speichert manchmal UTF8 statt ANSI

  Alt 13. Jun 2024, 17:49
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...
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.529 Beiträge
 
Delphi 12 Athens
 
#14

AW: TIniFile speichert manchmal UTF8 statt ANSI

  Alt 13. Jun 2024, 20:06
Zitat:
Spaß
Party
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 2     12   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:19 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz