.NET实现简繁体转换2008-09-12 10:02:02 来源:不详 作者:转载
最近到了台企,什么都要用繁体的。 开发中也遇到了简繁体转换的问题。 这里和朋友们分享一下用.net实现简繁体转换的经验。 我还是直接贴例子在说明一下吧: //Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using EncodeMy; namespace TestEnCode { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { EncodeRobert edControl = new EncodeRobert();//创建一个简繁转换对象 txtResult.Text= edControl.SCTCConvert(ConvertType.Simplified, ConvertType.Traditional,txtSource.Text);//进行简繁转换 } } } 注意:using EncodeMy;并非.net自带的类库,在Encode.dll中。要引用一下的。 请到http://download.csdn.net/source/617532 http://download.csdn.net/user/farawayplace613下载(不需要资源分的)该实例的代码。Encode.dll在Debug的文件夹内。 //Form1.Designer.cs namespace TestEnCode { partial class Form1 { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { this.txtSource = new System.Windows.Forms.TextBox(); this.txtResult = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // txtSource // this.txtSource.Location = new System.Drawing.Point(75, 26); this.txtSource.Name = "txtSource"; this.txtSource.Size = new System.Drawing.Size(100, 22); this.txtSource.TabIndex = 0; // // txtResult // this.txtResult.Location = new System.Drawing.Point(75, 126); this.txtResult.Name = "txtResult"; this.txtResult.Size = new System.Drawing.Size(100, 22); this.txtResult.TabIndex = 1; // // button1 // this.button1.Location = new System.Drawing.Point(75, 78); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 2; this.button1.Text = "简繁转换"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(23, 29); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(41, 12); this.label1.TabIndex = 3; t
|
|
||||
|
|
||||
|
|
|
||||
|
|
||||
|
|
|
||||
|
|
||||
|
|