Francois PIETTE wrote:
>>>> function TMyUnicodeIniFile.ReadString(const Section, Ident,
>>>> Default: string): string;
>>>> begin
>>>> result:=utf8decode(inherited ReadString(section, ident, default));
>>>> end;
>>>> 
>>>> procedure TMyUnicodeIniFile.WriteString(const Section, Ident,
>>>> Value: string);
>>>> begin
>>>> inherited WriteString(Section, Ident, Utf8Encode(Value));
>>>> end;
>>> 
>>> 
>>> That's the kind of code I had in mind.
>> 
>> 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 ).
> 
> What would be the issue ?
> Would quoted printable version be a better solution ?

That would work of course just like base 64 etc, but I suggust to use
a encoding that common text editors understand.

TIniFile as a base class is no solution IMO, since it's a wrapper
around Win32 API GetPrivateProfileString/WritePrivateProfileString.
One solution is to derive from TCustomIniFile with the same code as
in TMemIniFile except LoadValues and UpdateFile needs to be changed.
LoadValues and UpdateFile would handle conversion to and from
UTF-8 and would use OverbyteIcsStreams.TTextStream to read and write
lines to the file.
If TMemIniFile.LoadValues was declared Virtual we could derive from
TMemIniFile instead, but unfortunately it is not.

--
Arno Garrels  

> 
> --
> [EMAIL PROTECTED]
> The author of the freeware multi-tier middleware MidWare
> The author of the freeware Internet Component Suite (ICS)
> http://www.overbyte.be
-- 
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