Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-11

[PATCH] XMLCFG AnsiStringDOMString conversion

10 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

When I using xmlCfg unit i found problem with storing literals in arbitrary code page. XMLCfg perform automatic conversion with omit some chars.
I've change it to use utf8string instead of. Maybe this patch will be interesting.

Reply by email

Sergei Gorelkin
to Unknown author

пишет:

Show quoted text 6 lines
When I using xmlCfg unit i found problem with storing literals in arbitrary code page. XMLCfg perform automatic conversion with omit some chars. I've change it to use utf8string instead of. Maybe this patch will be interesting.

Such patch will make all existing config files with non-ascii data unreadable. In the meantime, I wrote the xmlconf unit exactly to avoid this problem. So if you need Unicode configs, you should switch to xmlconf. Calls to Utf8Encode/Decode will be still necessary because xmlconf.TXMLConfig has WideString parameters, but it won't strip any non-ascii data.

Regards,
Sergei

Reply by email

Dariusz Mazur
to Sergei Gorelkin

W dniu 2010-11-03 23:50, Sergei Gorelkin pisze:

Show quoted text 9 lines
пишет: > When I using xmlCfg unit i found problem with storing literals in > arbitrary code page. XMLCfg perform automatic conversion with omit some > chars. > I've change it to use utf8string instead of. Maybe this patch will be > interesting. > Such patch will make all existing config files with non-ascii data unreadable.

Today also. All nonasci charracter are translate to '?' during reading (implicit conversion widestring>ansistring).
On other side in XML should not be not asci char

Show quoted text 5 lines
In the meantime, I wrote the xmlconf unit exactly to avoid this problem. So if you need Unicode configs, you should switch to xmlconf. Calls to Utf8Encode/Decode will be still necessary because xmlconf.TXMLConfig has WideString parameters, but it won't strip any non-ascii data.

XMLCfg is enought to me,
but then you should add note that this unit is depreciated

Darek

Reply by email

Marco van de Voort
to Dariusz Mazur

In our previous episode, Dariusz Mazur said:

Show quoted text 8 lines
>> interesting. >> > Such patch will make all existing config files with non-ascii data > unreadable. Today also. All nonasci charracter are translate to '?' during reading (implicit conversion widestring>ansistring). On other side in XML should not be not asci char

This is not the same, current all chars in the current codepage (also above
127) will be fine. Only the ones NOT in the current codepage will turn up as '?' If you change to UTF-8, this will change.

Reply by email

Dariusz Mazur
to Marco van de Voort

W dniu 2010-11-04 17:44, Marco van de Voort pisze:

Show quoted text 11 lines
In our previous episode, Dariusz Mazur said: >>> interesting. >>> >> Such patch will make all existing config files with non-ascii data >> unreadable. > Today also. All nonasci charracter are translate to '?' during reading > (implicit conversion widestring>ansistring). > On other side in XML should not be not asci char This is not the same, current all chars in the current codepage (also above 127) will be fine. Only the ones NOT in the current codepage will turn up as '?' If you change to UTF-8, this will change.

then I have a question : how to change current code page

Darek

Reply by email

Sven Barth
to Dariusz Mazur: W dniu 2010-11-03 23:50, Sergei Gorelkin pisze: Today also. All nonasci charracter are…
Dariusz Mazur wrote
Today also. All nonasci charracter are translate to '?' during reading (implicit conversion widestring>ansistring). On other side in XML should not be not asci char

I don't know if you meant it that way (if not, you are free to ignore what I write here ^^), but a XML document may contain (nearly) any Unicode character even in tag and attribute names: http://en.wikipedia.org/wiki/XML#International_use

Regards,
Sven

Reply by email

Dariusz Mazur
to Felipe Monteiro de Carvalho

W dniu 2010-11-05 11:52, Felipe Monteiro de Carvalho pisze:

On Thu, Nov 4, 2010 at 7:51 PM, Dariusz Mazur wrote: > then I have a question : how to change current code page

I say wrong: how to change code page used to implicit conversion ansistring<-> wide string

You shouldn't. If you want to convert between code pages, then the

I don't want, but there is implicit conversion ansi<->wide, inside xmlcfg, depend on current code page. I assume, that this code page depend from OS, but this is bad for me, I need to control how chars are translated, because program can be use on different machines.

Darek

Reply by email

Felipe Monteiro de Carvalho
to Dariusz Mazur
Dariusz Mazur wrote
I say wrong: how to change code page used to implicit conversion ansistring<-> wide string

Use the appropriate conversion routine instead, and avoid implicit conversions for they are not reliable.

Felipe Monteiro de Carvalho

Reply by email

Sergei Gorelkin
to Felipe Monteiro de Carvalho

Felipe Monteiro de Carvalho пишет:

Show quoted text 7 lines
On Fri, Nov 5, 2010 at 6:15 PM, Dariusz Mazur wrote: > I say wrong: how to change code page used to implicit conversion > ansistring<-> wide string Use the appropriate conversion routine instead, and avoid implicit conversions for they are not reliable.

It is impossible to avoid implicit conversions with xmlcfg, because they occur within unit implementation.
I should have marked xmlcfg as deprecated a long time ago. Anyway, done in rev.16307.

Regards,
Sergei

Reply by email