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.
> 
> That's basically a good idea :-)

Do you want to reinvent the wheel ;-) 

> What about having a kind of quoted-printable (or any other encoding
> scheme) which would only encode characters which cannot be
> represented in the current ansi code page ? 

That takes more effort to decode and encode.
For example, any byte of characters above #255 has to be decoded quoted
printable and parts before and after those characters have to be converted
to ANSI with current codepage, rather complicated, isn't it?
The UTF-8 encoding is IMO best choice. I sent you my class that reads
ANSI as well as UTF-8 INI files (with or without BOM for best backwards
compatibility), it writes however allways UTF-8, if you do not use
characters above #127 UTF-8 is ASCII compatible and those files
could still be read by ICSv6.

--
Arno 

> This would have the
> advantage that most european countries wouldn't see anything special
> unless they use very uncommon unicode characters. Of course the ini
> file itself would not be transportable to another codepage but this
> is not a problem since it is for storing local data and not send data
> accross the world. 
> The disadvantage would be that text editor would
> not decode those unicode characters. Only asian countries and a few
> one using no latin characters would be less happy since most
> characters would be encoded. Anyway, it would work. 
> 
> After all, even if it is handy to use a text editor, the ini files in
> the demos are not intended to be edited. They are just storage for
> value grabbed from the user interface.
> 
> 
> --
> [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