Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread RTT
It is not that easy! The code above might work if String maps to an AnsiString, however fails if String maps to a UnicodeString ( Delpi 2009 ). This little modification does the job in D2009 uses rtlconsts; ... procedure TMyUnicodeIniFile.WriteString(const Section, Ident, Value:

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread Arno Garrels
RTT wrote: It is not that easy! The code above might work if String maps to an AnsiString, however fails if String maps to a UnicodeString ( Delpi 2009 ). This little modification does the job in D2009 uses rtlconsts; ... procedure TMyUnicodeIniFile.WriteString(const Section, Ident,

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread RTT
Yes, that should work and is the bare minimum required for use in the demos. Though it cannot handle a possible BOM. With a little trick and we just need to rewrite the create constructor. unit UnicodeIniFile; interface type TMyUnicodeIniFile = class(TIniFile) public constructor

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread Arno Garrels
RTT wrote: Yes, that should work and is the bare minimum required for use in the demos. Though it cannot handle a possible BOM. With a little trick and we just need to rewrite the create constructor. unit UnicodeIniFile; interface type TMyUnicodeIniFile = class(TIniFile) public

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread RTT
The D2009 TInitFile already uses the WritePrivateProfileStringW and GetPrivateProfileStringW versions of the functions, but only work if the ini file already exists and is Unicode. Surprise! That works indeed with UTF-16, however if there is a UTF-8 BOM and data I cannot read a

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread Arno Garrels
RTT wrote: The D2009 TInitFile already uses the WritePrivateProfileStringW and GetPrivateProfileStringW versions of the functions, but only work if the ini file already exists and is Unicode. Surprise! That works indeed with UTF-16, however if there is a UTF-8 BOM and data I cannot read a

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread RTT
As I wrote in my previous message, this does not work for me. Whenever Windows finds an UTF-8 BOM it does not return a single byte. Sorry, I have not understood. For me, the previous code works fine in Vista and XP. I change the encode of the ini file using Notepad from UTF16 to UTF8, and

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread Arno Garrels
Arno Garrels wrote: function TMyUnicodeIniFile.ReadString(const Section, Ident, Default: string): string; begin result := inherited; if fIsUTF8 then result := utf8decode(result) end; As I wrote in my previous message, this does not work for me. Whenever Windows finds an UTF-8 BOM

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread RTT
My fault, now it works. But it won't be the same level of backwards compatibility that can be achieved with a class derived from TCustomIniFile. Can you, please, point one possible problem? -- To unsubscribe or change your settings for TWSocket mailing list please goto

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread Francois PIETTE
It is also important that the INI file generated by D2009 compiled application remains compatible with the same application compiled with older Delphi as long as it is possible (This is not possible if a value stored in the INI file cannot be represented properly as an ansi character. See

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread RTT
Old Delphi saved ini files will open correctly in D2009 compiled demo too. It is also important that the INI file generated by D2009 compiled application remains compatible with the same application compiled with older Delphi as long as it is possible (This is not possible if a value

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread Francois PIETTE
Old Delphi saved ini files will open correctly in D2009 compiled demo too. It is also important that the INI file generated by D2009 compiled application remains compatible with the same application compiled with older Delphi as long as it is possible (This is not possible if a value stored in

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread Arno Garrels
RTT wrote: My fault, now it works. But it won't be the same level of backwards compatibility that can be achieved with a class derived from TCustomIniFile. Can you, please, point one possible problem? If you derive something like the TMemInFile that writes all data in one call to a method

Re: [twsocket] Proposal to replace TIniFile byTRegIniFile in all v7 demo applications

2008-11-09 Thread RTT
If you derive something like the TMemInFile that writes all data in one call to a method UpdateFile it's possible to add a BOM or not depending on the data itself. You can read a BOM-marked UTF-8 INI + file, change it and write it back as Ansi or plain Ascii without BOM if encoding is no