Delphi:将rtf转换成文本的最佳方式 [英] Delphi: best way to convert rtf to text

查看:281
本文介绍了Delphi:将rtf转换成文本的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将rtf转换为纯文本。我曾经写过一个删除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.

所以一个选项可以使用在运行时创建的TRichEdit(类似于这里,但当然完成在运行时)。但还有另一种方式吗?是否有一个rtl功能或更好的方法?

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?

更新:

这个问题我将rtf的最终版本写入文本过程。

In this question I wrote the final version of my rtf to text procedure.

推荐答案

如果你真的想找到一个这样做的转换方式,你应该看看类TConversion如何在类TRichEditStrings中实现。这些类在ComCtrls.pas中。通过了解如何在RichEdit控件中完成转换,您可以编写自己的。

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.

然而,看看实现这一点的实际方面并不知道什么性能要求是为了您的问题,我将去链接中概述的TRichEdit转换方法。

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.

这篇关于Delphi:将rtf转换成文本的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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