AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein ini file , readstring UTF vs. ASCII

ini file , readstring UTF vs. ASCII

Ein Thema von bernhard_LA · begonnen am 26. Jul 2021 · letzter Beitrag vom 12. Okt 2021
Antwort Antwort
bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.142 Beiträge
 
Delphi 11 Alexandria
 
#1

AW: ini file , readstring UTF vs. ASCII

  Alt 12. Okt 2021, 08:48
a) wenn ich die Ini files Klasse weiterhin verwenden will, benötige ich einen Check auf BOM , ich habe diesen code hierzu gefunden https://www.delphi-treff.de/tipps-tr...rung-erkennen/
eine extra Zeile Code und eine Exception werfen wenn das BOM Flag gefunden wird ?


b) bei dieser Option , von https://docwiki.embarcadero.com/Code...niFile_(Delphi),
wie übergebe ich den Filenamen an meine Settingsklasse ?
Die Funktion OpenIniFileInstance() ist leider nicht erklärt


Delphi-Quellcode:

var
  SettingsFile : TCustomIniFile;
begin
  { Open an instance }
  SettingsFile := OpenIniFileInstance();

  try
    {
    Read all saved values from the last session. The section name
    is the name of the form. Also use the form's properties as defaults.
    }

    Top := SettingsFile.ReadInteger(Name, 'Top', Top );
    Left := SettingsFile.ReadInteger(Name, 'Left', Left );
    Width := SettingsFile.ReadInteger(Name, 'Width', Width );
    Height := SettingsFile.ReadInteger(Name, 'Height', Height );
    Caption := SettingsFile.ReadString (Name, 'Caption', Caption);

    { Load last window state. }
    case SettingsFile.ReadBool(Name, 'InitMax', WindowState = wsMaximized) of
      true : WindowState := wsMaximized;
      false: WindowState := wsNormal;
    end;

  finally
    SettingsFile.Free;
  end;
end;
PS : diesmal wurde die Datei mit dem Notepad++ erstellt

Geändert von bernhard_LA (12. Okt 2021 um 09:19 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

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

AW: ini file , readstring UTF vs. ASCII

  Alt 12. Okt 2021, 09:28
Erstmal, INI-Dateiteien der WinAPI gibt es ausschließlich in ANSI oder UTF-16 (ohne BOM).

Dein Problem dürfte sich aber durch die TStringList lösen lassen, also mit RadioGroup1.ItemIndex=2.


Zitat:
PS : diesmal wurde die Datei mit dem Notepad++ erstellt
Das darf man gern machen, aber beim Speichern wählt man dann gefälligst auch das richtige Format.

Zitat:
Check auf BOM
Da gibt es auch was von Ratiof TEncoding.

Zitat:
Die Funktion OpenIniFileInstance() ist leider nicht erklärt
Die ist doch selbsterklärend?
Ein Therapeut entspricht 1024 Gigapeut.

Geändert von himitsu (12. Okt 2021 um 09:33 Uhr)
  Mit Zitat antworten Zitat
bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.142 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: ini file , readstring UTF vs. ASCII

  Alt 12. Okt 2021, 12:10
nicht ganz, weil meiene naheliegende Lösung hier dann einen Abstract Fehler zurückliefert ....



Delphi-Quellcode:
  
var
  IniFile: TCustomIniFile;
  if FileExists(filename) then
  begin
    IniFile := TCustomIniFile.Create(filename);
    try
      Result := IniFile.ReadString(SectionStr, IdentStr, '<none>');
    finally
      IniFile.Free;
    end;
  end
  else
  begin
    Result := '<no file found>';
  end;
  Mit Zitat antworten Zitat
Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.784 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: ini file , readstring UTF vs. ASCII

  Alt 12. Okt 2021, 12:58
.. aus der Hilfe..
Zitat:
Note: Use TCustomIniFile as a base class when defining components that access ini files. Ini files are text files that are divided into sections with variable assignments in each section. TCustomIniFile introduces properties and methods to handle storage and retrieval of application-specific information and settings in a standard ini file.

..

Do not create instances of TCustomIniFile. Instead, use or create descendants of TCustomIniFile, such as TIniFile, TRegistryIniFile, and TMemIniFile
Grüße
Klaus
Klaus
  Mit Zitat antworten Zitat
Antwort Antwort

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

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 19:58 Uhr.
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