如何快速检查RTF(纯文本)文本内容是否为空 [英] How can I check very quick if the RTF (Plain) text content is empty

查看:159
本文介绍了如何快速检查RTF(纯文本)文本内容是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我需要知道RTF是否具有真实的文本内容,例如至少一个char,空格或回车符,并且它不是完全为空.长度没关系!

我不想通过将整个文本转换为纯文本并检查文本长度或使用特殊控件来进行检查.

例如,是否可以在原始RTF文本上使用RegEx或类似方法来检查此内容?

谢谢和问候,

Michael

Hello,

I need to know if a RTF has a real text content such as at least one char, space or carriage return and it is not completly empty. The length doesn''t matter!

I do not want to check this by converting the whole text into plaintext and examine the text length or using a special control.

For example is there any way using RegEx on the raw RTF text or something like that to check this?

Thanks and Regards,

Michael

推荐答案

这并不是对您有帮助,但我想不出任何简单的方法.

作为一项快速实验,我在OpenOffice中创建了一个空白rtf文件,保存时为3kb.在Word中创建的另一个是2kb.因此,文件大小不是可靠的指南.

我尚未对此进行测试,但是Windows窗体RichTextBox控件具有TextLength属性,因此从理论上讲,您可以创建内存中的RichTextBox,加载文件并读取TextLength.正如我所说,我尚未测试过,因此不确定返回的长度是否正确.

祝你好运. :)
Not that it will help you but I cannot think of any easy way to do this.

As a quick experiment I created a blank rtf file in OpenOffice and when saved it was 3kb. Another one created in Word was 2kb. The file size is therefore not a reliable guide.

I haven''t tested this but the Windows Forms RichTextBox control has a TextLength property, so theoretically you could create an in-memory RichTextBox, load in the file and read the TextLength. As I say, I haven''t tested it and am therefore not sure if the length returned is accurate.

Good luck. :)


这篇关于如何快速检查RTF(纯文本)文本内容是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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