dxDBGrid1.SaveToXML(filename,true)方法,得到的结果中如果有中文出乱码,怎么解决 dxDBGrid1.SaveToXML(filename,true)方法,得到的结果文件中,如果是英文和数字没问题,但结果中如果有中文就会出现乱码,怎么才能解决 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 呵呵,你说的问题看了看,确实是有这个问题的。不过如果你手头有源代码,你可以把以下部分修改下,再重新编译,就可以了。但是我在实际使用的并不是很多,因此可能有bug我没有发现,如果有你自己再优化吧。我使用的dxDBGrid是3.2.2版本的。打开dxGrExpt.pas单元到258行将看到的函数改成下列function ConvertTextToXml(const AText: string): string;const NormalAlpha = ['0'..'9', ':', ';', '*', '+', ',', '-', '.', '/', '!', ' ', 'A'..'Z', 'a'..'z', '_'];var I: Integer;begin Result := AText;//不进行转换 //以下不用 {for I := 1 to Length(AText) do if AText[I] in NormalAlpha then Result := Result + AText[I] else Result := Result + Format('&#%d;', [Ord(AText[I])]); }end;将1607行的procedure TdxDBGridExportXSL.WriteContent;主体函数的第一行改为WriteLn('<?xml version="1.0" encoding="GB2312" standalone="yes" ?>');将1738行改为:procedure TdxDBGridExportXML.DoBeginWriting;begin FIndentCharCount := 0; WriteLn('<?xml version = "1.0" encoding="GB2312" standalone="yes" ?>');//增加中文字符集 WriteXSL; WriteDTD; WriteLn('<GRID ExportVersion="1.0">');end; free007(绝色蜜蜂) ,谢谢你的指导,不过我有一行没弄明白怎么改,请再指导一下^_*将1607行的procedure TdxDBGridExportXSL.WriteContent;主体函数的第一行改为WriteLn('<?xml version="1.0" encoding="GB2312" standalone="yes" ?>');主体函数在哪呀?呵呵 XML偶不知道,但若是HTML的話,我建議樓主讓程序加上<..... charset...="gb2312"> 之類的! 他不是是个嵌套函数么?你直接搜索WriteLn('<?xml version="1.0" 这个,找到了看看是不是在procedure TdxDBGridExportXSL.WriteContent内,是就修改不就行了么? 关于XML文件读取和写入 急 在线等ADOCommand1.Parameters.ParamByName的问题 超急簡單問題! 在线等答案! 关于回调的机制。。。请各位大哥帮忙。 各位看官赐教了——adostoredproc控件的updatebatch功能怎么用? 弹出式的浏览目录的对话框该怎样实现,代码怎么写? 500分求足彩“合成复式”算法,关键是速度要快(分不够可再加)!! 关于delphi的opengl控件,哪里可以下载?一定送分!!! 如何得到WinAPI的delphi版本帮助?(不是c++版本) 工具选择 【求助】在win2000和winXP中如何实现键盘和鼠标的全面锁定?
我使用的dxDBGrid是3.2.2版本的。
打开dxGrExpt.pas单元
到258行
将看到的函数改成下列
function ConvertTextToXml(const AText: string): string;
const
NormalAlpha = ['0'..'9', ':', ';', '*', '+', ',', '-', '.', '/', '!', ' ',
'A'..'Z', 'a'..'z', '_'];
var
I: Integer;
begin
Result := AText;//不进行转换
//以下不用
{for I := 1 to Length(AText) do
if AText[I] in NormalAlpha then
Result := Result + AText[I]
else
Result := Result + Format('&#%d;', [Ord(AText[I])]); }
end;
将1607行的procedure TdxDBGridExportXSL.WriteContent;主体函数的第一行改为
WriteLn('<?xml version="1.0" encoding="GB2312" standalone="yes" ?>');
将1738行改为:
procedure TdxDBGridExportXML.DoBeginWriting;
begin
FIndentCharCount := 0;
WriteLn('<?xml version = "1.0" encoding="GB2312" standalone="yes" ?>');//增加中文字符集
WriteXSL;
WriteDTD;
WriteLn('<GRID ExportVersion="1.0">');
end;
WriteLn('<?xml version="1.0" encoding="GB2312" standalone="yes" ?>');主体函数在哪呀?呵呵
<..... charset...="gb2312"> 之類的!