如何将 RTF 文件分割成行?
我试图将 RTF 文件分割成行(在我的代码中),但我不太正确,主要是因为我并没有真正理解整个 RTF 格式。看起来行可以用 \par 或 \pard 或 \par\pard 或任何数量的有趣组合来分割。
我正在寻找一段代码,可以将文件分割成任何语言的行。
I am trying to split an RTF file into lines (in my code) and I am not quite getting it right, mostly because I am not really grokking the entirety of the RTF format. It seems that lines can be split by \par or \pard or \par\pard or any number of fun combinations.
I am looking for a piece of code that splits the file into lines in any language really.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试 规范 ( 1.9.1)(参见维基百科页面上的外部链接 - 其中还有一些指向多种编程语言的示例或模块的链接)。
这很可能会让您了解行插入“单词”,因此您可以使用一组明确定义的规则将文件拆分为行,而不是猜测它。
You could try the specification (1.9.1) (see External Links on the Wikipedia page - which also has a couple of links to examples or modules in several programming languages).
That would most likely give you an idea of the line insertion "words", so you can split the file into lines using a well-defined set of rules rather than taking a guess at it.
您是否读过 O'Reilly 的 RTF Pocket Guide,作者:Sean M. Burke?
在第 13 页上,它说
以下是在 RTF 中放置换行符的一些经验法则:
或者您是否正在考虑将明文提取为行,并且无论明文的语言是什么?
Have you come across O'Reilly's RTF Pocket Guide, by Sean M. Burke ?
On page 13, it says
Here are some rules of thumb for putting linebreaks in RTF:
Or were you thinking of extracting the plaintext as lines, and doing it whatever the language of the plaintext?
我编写了一个快速而肮脏的例程,它似乎适用于我能扔给它的几乎所有东西。它是用 VB6 编写的,但可以轻松转换为其他任何内容。
I coded up a quick and dirty routine and it seems to work for pretty much anything I've been able to throw at it. It's in VB6, but easily translatable into anything else.