asp.Netにおける簡体字変換繁体字実装コード

4861 ワード

私はやはり直接例を貼って説明しましょう.
 
  
//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
{
///
/// 。
///

private System.ComponentModel.IContainer components = null;
///
/// 。
///

/// , true; false。
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows
///
/// -
/// 。
///

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;
this.label1.Text = " ";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 136);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 4;
this.label2.Text = " ";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(320, 277);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.txtResult);
this.Controls.Add(this.txtSource);
this.Name = "Form1";
this.Text = " ";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox txtSource;
private System.Windows.Forms.TextBox txtResult;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
}
}

なお、上からダウンロードしたのはVS 2008で作成するアイテムである.
コードを自分の環境にコピーする必要があるかもしれません.ダウンロードで重要なのはEncodeです.dll.
ははは、簡単にしましょう.2つの文で繁体字の変換ができました.
著者:程呈
原文:http://blog.csdn.net/farawayplace613/archive/2008/09/10/2910527.aspx