本文主要向大家介绍了C/C++知识点之C#之使用StringHelper来处理汉字转拼音,通过具体的内容向大家展示,希望对大家学习C/C++知识点有所帮助。
StringHelper字符串处理帮助
现在已经实现的功能有:
1.用给定的字符填充源字符串的左边以达到指定的长度
2.用给定的字符填充源字符串的右边以达到指定的长度
3.转半角的函数(DBC case)
4.转全角的函数(SBC case)
5.汉字转拼音缩写
6.取单个字符的拼音声母
等等
演示一下:汉字转拼音缩写
我是那Windows窗体写的
代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace PyCodeDemo{ public partial class Form1 : Form
{ public Form1() {
InitializeComponent();
} private void label1_Click(object sender, EventArgs e) {
} private void button1_Click(object sender, EventArgs e) { this.label1.Text = StringHelper.PYConvert(this.textBox1.Text.Trim(), true);
}
}
}
实现后的结果:
下面看一下StringHepler的代码:using