Delphi:将 rtf 转换为文本的最佳方法
我需要将 rtf 转换为纯文本。我曾经编写过一个去除 rtf 标头的函数,但它从来都不是完美的。
因此,一种选择是使用在运行时创建的 TRichEdit(类似于 此处 但当然是在运行时完成的)。但还有别的办法吗?是否有一个 rtl 函数或者更好的方法?
更新:
在这个问题中,我写了我的最终版本rtf 转文本程序。
I need to convert rtf to plain text. i used to write a function that strips away rtf headers but it is never perfect.
So one option can be using a TRichEdit created at runtime (something like described here but done of course at runtime). But is there another way? Is there an rtl function for this or a better approach?
UPDATE:
In this question I wrote the final version of my rtf to text procedure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您确实想找到一种执行此转换的方法,您应该看看 TConversion 类是如何在 TRichEditStrings 类中实现的。这些类位于 ComCtrls.pas 中。通过了解 RichEdit 控件内部如何完成转换,您也许能够编写自己的控件。
然而,考虑到实现这一点的实际方面,并且不知道您的问题的性能要求是什么,我会选择您链接中概述的 TRichEdit 转换方法。
If you really want to find a way of doing this conversion you should take a look at how the class TConversion is implemented in the class TRichEditStrings. These classes are in ComCtrls.pas. By understanding how the conversion is done inside the RichEdit controls you may be able to write your own.
However, looking at the practical aspects of implementing this and not knowing what the performance requirements are for your question I would go for the TRichEdit conversion approach outlined in your link.