无法阅读“”字符形式ini文件与tinifile.readstring [英] Cannot read "" character form ini file with tinifile.readstring

查看:91
本文介绍了无法阅读“”字符形式ini文件与tinifile.readstring的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i有一个用Delphi 7编写的小程序。

我将文本保存到Ini文件然后读取这个来自ini文件的文本,方法为ReadString。

但是,当保存文本包含或字符时,我无法读取这些字符。

Ex:

我将文本注释1和注释2保存为第01项,按键o2保存在部分注释中

结果ini文件为:

[评论]

01 =评论1

02 ='评论2'

当我读到它时,结果是

评论1

评论2



我不知道为什么结果文本不包含和'字符。

请帮我解决。

我想要的结果文本与ini文件中的保存文本相同。



代码:

Hi all,

i have a small program written with Delphi 7.
I save a text into Ini file and then read this text from ini file with method ReadString.
However, when save text contain " or ' character, i cannot read these character.
Ex:
I save text "Comment 1" and 'Comment 2' with key 01 and key o2 at section comment
Result in ini file is:
[Comment]
01="Comment 1"
02='Comment 2'
When i read it, result is
Comment 1
Comment 2

I don't know why result text does not contain "" and '' character.
Please help me fix it.
I want result text is same with save text in ini file.

code:

comment := IniFile.ReadString(iniSection, Format('%.02d',[index]), EmptyStr);





谢谢



我试过的:



我不知道解决方案。

如果您有任何解决方案,请帮助我。



Thanks

What I have tried:

I don't know solution.
If you have any solution, please help me.

推荐答案

请看我对这个问题的评论。



当然,问题很容易解决。但我宁愿提出另一种想法。



为什么要使用从未标准化且有严重限制的过时格式?使用一些强大的标准化格式,例如XML。



使用Embarcadero,解决方案是:使用TXMLDocument - RAD Studio



但我会认真地建议解决开源问题。主要来源是Free Pascal。如果需要,您可以下载所有源代码并在Delphi中构建解决方案。请参阅:

fcl-xml - Lazarus wiki

XML教程 - 免费Pascal wiki



此外,还有一个第三方解决方案的数量。一个有趣的方法是Libxml2包装器,它也使SAX可用: Libxml2 for pascal download | SourceForge.net [ ^ ]。



我强烈建议密切关注Free Pascal和Lazarus(IDE,但也是一个跨平台的UI库,LCL):

Lazarus wiki

Lazarus主页(在其设置中包括完整的Free Pascal安装)。



这个开源产品变得非常强大和强大。与Delphi相比,它更像是一个跨平台的产品,也许是最强大的跨平台产品,在生成本机代码的程序系统世界中可以使用UI,并且覆盖了最广泛的平台。



-SA
Please see my comment to the question.

Of course, the problem is easy to work around. But I would rather suggest an alternative idea.

Why using obsolete format which never was standardized and have serious limitations? Use some robust and standardized format, such as XML.

With Embarcadero, the solution is this: Using TXMLDocument — RAD Studio.

But I would seriously recommend to address to open source. The main source is Free Pascal. You can download all the source code and build the solution in Delp if you want. Please see:
fcl-xml — Lazarus wiki,
XML Tutorial — Free Pascal wiki.

Also, there is a number of 3rd-party solution. One interesting approach is the Libxml2 wrapper, which also makes SAX available: Libxml2 for pascal download | SourceForge.net[^].

And I would strongly advice to pay close attention for Free Pascal and Lazarus (IDE but also a cross-platform UI library, LCL):
Lazarus wiki,
Lazarus Homepage (includes full Free Pascal installation in its setup).

This open-source product became very strong and robust. Compared to Delp it's much more of a cross-platform product, perhaps the most powerful cross-platform with UI available in the worlds of programing systems producing native code, with the widest set of platforms covered.

—SA


全部谢谢。



我有解决方案对于这个问题。

使用TMemIniFile替换TIniFile,这个问题就解决了。
Thanks all.

I had solution for this problem.
Use TMemIniFile replace TIniFile, this problem will be solved.


这篇关于无法阅读“”字符形式ini文件与tinifile.readstring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆