1 Star 0 Fork 0

W意波/rtf2txt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Program.cs 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
W意波 提交于 2020-06-15 10:37 . 修改代码,完成功能测试
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TtfToTxt
{
class Program
{
static void Main(string[] args)
{
Random r = new Random();
char[] chs = new char[32];
for (int i = 0; i < chs.Length; ++i)
chs[i] = (char)r.Next(1, 127);
Test(new string(chs));//随机字符串
Test("测试\r\\\t\n\"字符串\'");//可以换成其他内容测试
Console.Read();
}
//简单的 txt->Rtf->txt 测试
static void Test(string txt) {
System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox();
rtb.Text = txt;
//通过RichTextBox转为Rtf格式文本
var result = rtf2txt.RtfToTxt(rtb.Rtf);
Console.WriteLine("RTF文本:\n" + rtb.Rtf + "\n");
Console.WriteLine("原始文本:\n" + txt);
Console.WriteLine("识别文本:\n" + result);
Console.WriteLine("\n相等比较:" + (rtb.Text == result)+"\n");
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/bidai/rtf2txt.git
git@gitee.com:bidai/rtf2txt.git
bidai
rtf2txt
rtf2txt
master

搜索帮助