解决撰写毕业论文时知网空格处理与中英字符串转化
2018-01-19 22:26
295 查看
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace Trim { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void richTextBox1_TextChanged(object sender, EventArgs e) { // richTextBox1.BackColor = Color.Green; } private void 转化_Click(object sender, EventArgs e) { string strWrite = string.Empty; string strRead = richTextBox1.Text; CharEnumerator CEnumerator = strRead.GetEnumerator(); while (CEnumerator.MoveNext()) { byte[] array = new byte[1]; array = System.Text.ASCIIEncoding.ASCII.GetBytes(CEnumerator.Current.ToString()); int asciicode = (short)(array[0]); if (asciicode != 32) { strWrite += CEnumerator.Current.ToString(); } } richTextBox2.Text = strWrite; //Console 输出字符串 } private void button1_Click(object sender, EventArgs e) { string strWrite = string.Empty; string strRead = richTextBox1.Text; CharEnumerator CEnumerator = strRead.GetEnumerator(); while (CEnumerator.MoveNext()) { byte[] array = new byte[1]; array = System.Text.ASCIIEncoding.ASCII.GetBytes(CEnumerator.Current.ToString()); int asciicode = (short)(array[0]); if (asciicode != 32) { strWrite += CEnumerator.Current.ToString(); } } //Console 输出字符串 string l_strResult = strWrite.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", ""); richTextBox2.Text = l_strResult; } private void Form1_Load(object sender, EventArgs e) { } private void 转化ToolStripMenuItem_Click(object sender, EventArgs e) { string strWrite = string.Empty; string strRead = richTextBox1.Text; CharEnumerator CEnumerator = strRead.GetEnumerator(); while (CEnumerator.MoveNext()) { byte[] array = new byte[1]; array = System.Text.ASCIIEncoding.ASCII.GetBytes(CEnumerator.Current.ToString()); int asciicode = (short)(array[0]); if (asciicode != 32) { strWrite += CEnumerator.Current.ToString(); } } richTextBox2.Text = strWrite; //richTextBox2.Copy(); //richTextBox2.Paste(); } private void 打开文件ToolStripMenuItem_Click(object sender, EventArgs e) { try { openFileDialog1.Filter = ""; openFileDialog1.ShowDialog(); //textBox1.Text = openFileDialog1.FileName; StreamReader sreader = new StreamReader(openFileDialog1.FileName, Encoding.Default); //openFileDialog1. // if (Directory.Exists(openFileDialog1.FileName)) // { richTextBox1.Text = sreader.ReadToEnd(); sreader.Close(); // } // else // { // MessageBox.Show("输入文件名不能为空"); //} } catch (FormatException) { return; } } private void 保存文件ToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; string character=richTextBox2.Text; StreamWriter myStream; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { myStream = new StreamWriter(saveFileDialog1.FileName); myStream.Write(richTextBox2.Text); // Code to write the stream goes here. myStream.Close(); } } private void 清空所有文本ToolStripMenuItem_Click(object sender, EventArgs e) { richTextBox1.Clear(); richTextBox2.Clear(); } private void 复制结果ToolStripMenuItem_Click(object sender, EventArgs e) { if (richTextBox2.Text.Trim() == String.Empty) { MessageBox.Show("孬孬提示:没有要粘贴的内容!"); } else Clipboard.SetText(richTextBox2.Text); } private void 符号处理ToolStripMenuItem_Click(object sender, EventArgs e) { string strWrite = string.Empty; string strRead = richTextBox1.Text; CharEnumerator CEnumerator = strRead.GetEnumerator(); while (CEnumerator.MoveNext()) { byte[] array = new byte[1]; array = System.Text.ASCIIEncoding.ASCII.GetBytes(CEnumerator.Current.ToString()); int asciicode = (short)(array[0]); c438 if (asciicode != 32) { strWrite += CEnumerator.Current.ToString(); } } //Console 输出字符串 string l_strResult = strWrite.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace(".", "。").Replace(",",","); richTextBox2.Text = l_strResult; //richTextBox2.Copy(); } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("确定萌萌的关闭文字处理小助手么?", "确定离开", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { e.Cancel = true; } } private void Form1_DoubleClick(object sender, EventArgs e) { MessageBox.Show("别点啦"); } private void Form1_MouseEnter(object sender, EventArgs e) { } } }
百度云下载链接:
一个处理直接从知网复制论文出现的空格,中英字符转化的小软件
相关文章推荐
- 对uuid的处理,将其字符串转化为大写并无空格
- 关于String字符串空格的处理[用(char)12288解决空格问题]
- 解决Python字符串处理出现错误UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe4 in position 108: ordinal not in range(128)
- java各种处理字符串情况乱码原因分析及其解决方法
- Python处理json字符串转化为字典的简单实现
- JSTL字符串处理的两种解决方法
- 如何解决 html 中多空格字符被当作一个空格字符处理的问题
- 字符串处理,替换忽略大小写,空格
- 字符串处理函数 TRIM - 去掉首尾空格
- 字符串空格的处理
- C# Split 分隔符为字符串及空格的处理
- c语言字符串分割函数mysplit,可处理多个空格
- JSON字符串传到后台PHP处理问题的解决方法
- 在BAT文件中实现对空格分割的字符串的处理
- 删除字符串开始及末尾的空白符,并且把数组中间的多个空格(如果有)符转化为1个
- springbatch 读取csv文件时 文件中有字符串需要转换为Date类型的字段报错字符串不能转化为Date类型的解决方法
- 删除字符串开始及末尾的空白符,并且把数组中间的多个空格(如果有)符转化为1个。
- iOS NSDecimalNumber用法 加减乘除 解决字符串转float类型不准确 结尾无法去0处理 用于货币处理
- 在python中处理字符串中的空格和换行符