how set code page to export xml file ion progress 4gl

271 views Asked by At

In the case when generating the xml I wanted to define the utf-16 code page when generating the file in the command:

hDoc: SAVE ("file", "c: \ tmp \ lantek.xml"). (export to utf-16) 
1

There are 1 answers

0
Stefan Drissen On

You will need to use an intermediate longchar variable which has had it's codepage fixed.

def var hxdoc   as handle.
def var hxn     as handle.
def var hxnt    as handle.
def var lcc     as longchar.

create x-document hxdoc.
create x-noderef hxn.
create x-noderef hxnt.

hxdoc:create-node( hxn, 'root', 'element' ).
hxdoc:append-child( hxn ).
hxdoc:create-node( hxnt, '', 'text' ).
hxn:append-child( hxnt ).

hxnt:node-value = 'røøt'.

fix-codepage( lcc ) = 'utf-16'. // remove to see difference

hxdoc:save( 'longchar', lcc ).

message 
    length( lcc, 'raw' ) skip
    string( lcc )
    .

copy-lob from lcc to file 'foobar.xml'. // you may need no-convert

When fix-codepage is not used, the length of the longchar is 42. When the codepage has been set to utf-16 the length of the longchar is 84.

Example at abldojo.progress.com.