问题描述
在生成xml的情况下,我想在命令中生成文件时定义utf-16代码页:
hDoc: SAVE ("file","c: \ tmp \ lantek.xml"). (export to utf-16)
解决方法
您将需要使用一个中间 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 处的示例。