当前位置: 代码迷 >> PB >> DataWindow的ImportString(XML!xmlstr)包含中文时报UTFDataFormatException有关问题
  详细解决方案

DataWindow的ImportString(XML!xmlstr)包含中文时报UTFDataFormatException有关问题

热度:79   发布时间:2016-04-29 08:40:23.0
DataWindow的ImportString(XML!,xmlstr)包含中文时报UTFDataFormatException问题
pb11.5做的程序使用DataWindow的ImportString(XML!,xmlstr)导入xml数据到dw模板中。
当xml中的所有节点值都是数值或字母时ImportString成功,但xmlstr中某个节点的值是中文时,就会报以下错误:
error parsing XML document:
An exception occurred! Type:UTFDataFormatException,Message:invalid byte 1() of a 1-byte sequence PBSaxparser,Line:1,Position:1.

经测试,使用ImportFile(XML!,)时,如果文件是utf-8字符格式,就不会报错,如果是bg2312也会出现上述错误。
但程序内怎么把接收到的xmlstr转为utf-8格式的字符串呢?
谢谢啦,哪怕是简单的指点都不胜感激!

------解决方案--------------------
FileReadEx 函数读到blob里,然后用string函数转换时,指定为EncodingUTF8!编码
  相关解决方案