Delphi:将 rtf 转换为文本的最佳方法

发布于 2024-09-09 00:28:13 字数 438 浏览 0 评论 0原文

我需要将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

川水往事 2024-09-16 00:28:13

如果您确实想找到一种执行此转换的方法,您应该看看 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文