首页 > 解决方案 > 如何设置代码页以导出 xml 文件离子进度 4gl

问题描述

在生成xml的情况下,我想在命令中生成文件时定义utf-16代码页:

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

标签: xmlexportopenedgeprogress-4gl4gl

解决方案


您将需要使用已修复其代码页的中间 longchar 变量。

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

fix-codepage不使用时,longchar 的长度为 42。当 codepage 设置为 utf-16 时,longchar 的长度为 84 。

abldojo.progress.com上的示例。


推荐阅读