>> 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 
> the INI file cannot be represented properly as an ansi character. See a 
> message I wrote ealier).
>
> This compatibility will avoid a lot of headache to all ICS developpers when 
> testing ICS accross many compilers. It would be a nuisance to "fix" the INI 
> file each time you switch from D2009 to a previous version. It is already 
> enough a nuisance to have the dproj file broken by D2009 !
>   
This code already provide old Delphi versions compiled demos the 
possibility to read BOM marked files created by D2009 ICS demos.
To make it completely compatible there is only the need to not BOM mark 
new files when using non Unicode Delphi

constructor TMyUnicodeIniFile.Create(const aFileName: string);
var f: TfileStream;
i:integer;
const UnicodeBOM: word = $FEFF;
      UTF8BOM:Integer=$00BFBBEF;
begin
 {$IFDEF UNICODE}
 if not fileexists(aFileName) then
 begin
 f:=Tfilestream.Create(aFilename,fmCreate);
 try
   f.Write(UnicodeBOM, 2);
 finally
   f.Free;
 end
 end else
{$ENDIF}
 begin
 f:=Tfilestream.Create(aFilename,fmOpenRead);
 try
   i:=0;
   f.read(i, sizeof(i));
   fIsUTF8:=i and $00ffffff=UTF8BOM;
 finally
   f.Free;
 end;
 end;
 inherited;
end;

Obviously, if the ini file contain a string that can not be codepage 
mapped, will show up with ??? in old Delphi compiled demos, but this is 
a consequence of non Unicode applications.


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to