asp.net中簡(jiǎn)體轉(zhuǎn)繁體實(shí)現(xiàn)代碼
更新時(shí)間:2010年03月10日 22:59:33 作者:
最近到了臺(tái)企,什么都要用繁體的。開(kāi)發(fā)中也遇到了簡(jiǎn)繁體轉(zhuǎn)換的問(wèn)題。這里和朋友們分享一下用.net實(shí)現(xiàn)簡(jiǎn)繁體轉(zhuǎn)換的經(jīng)驗(yàn)。
我還是直接貼例子在說(shuō)明一下吧:
//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();//創(chuàng)建一個(gè)簡(jiǎn)繁轉(zhuǎn)換對(duì)象
txtResult.Text= edControl.SCTCConvert(ConvertType.Simplified, ConvertType.Traditional,txtSource.Text);//進(jìn)行簡(jiǎn)繁轉(zhuǎn)換
}
}
}
注意:using EncodeMy;并非.net自帶的類(lèi)庫(kù),在Encode.dll中。要引用一下的。
請(qǐng)到http://download.csdn.net/source/617532
http://download.csdn.net/user/farawayplace613下載(不需要資源分的)該實(shí)例的代碼。Encode.dll在Debug的文件夾內(nèi)。
//Form1.Designer.cs
namespace TestEnCode
{
partial class Form1
{
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
/// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要
/// 使用代碼編輯器修改此方法的內(nèi)容。
/// </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 = "簡(jiǎn)繁轉(zhuǎn)換";
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 = "轉(zhuǎn)換源";
//
// 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 = "轉(zhuǎn)換結(jié)果";
//
// 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 = "簡(jiǎn)繁體轉(zhuǎn)換測(cè)試";
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;
}
}
注意了,上面下載地下載的是VS2008創(chuàng)建的項(xiàng)目.
可能需要你把代碼拷貝到你自己的環(huán)境中。下載中重要的是Encode.dll。
哈哈,簡(jiǎn)單吧,就兩句就搞定了簡(jiǎn)繁體的轉(zhuǎn)換。
作者:程呈
原文來(lái)自:http://blog.csdn.net/farawayplace613/archive/2008/09/10/2910527.aspx
復(fù)制代碼 代碼如下:
//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();//創(chuàng)建一個(gè)簡(jiǎn)繁轉(zhuǎn)換對(duì)象
txtResult.Text= edControl.SCTCConvert(ConvertType.Simplified, ConvertType.Traditional,txtSource.Text);//進(jìn)行簡(jiǎn)繁轉(zhuǎn)換
}
}
}
注意:using EncodeMy;并非.net自帶的類(lèi)庫(kù),在Encode.dll中。要引用一下的。
請(qǐng)到http://download.csdn.net/source/617532
http://download.csdn.net/user/farawayplace613下載(不需要資源分的)該實(shí)例的代碼。Encode.dll在Debug的文件夾內(nèi)。
復(fù)制代碼 代碼如下:
//Form1.Designer.cs
namespace TestEnCode
{
partial class Form1
{
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
/// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要
/// 使用代碼編輯器修改此方法的內(nèi)容。
/// </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 = "簡(jiǎn)繁轉(zhuǎn)換";
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 = "轉(zhuǎn)換源";
//
// 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 = "轉(zhuǎn)換結(jié)果";
//
// 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 = "簡(jiǎn)繁體轉(zhuǎn)換測(cè)試";
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;
}
}
注意了,上面下載地下載的是VS2008創(chuàng)建的項(xiàng)目.
可能需要你把代碼拷貝到你自己的環(huán)境中。下載中重要的是Encode.dll。
哈哈,簡(jiǎn)單吧,就兩句就搞定了簡(jiǎn)繁體的轉(zhuǎn)換。
作者:程呈
原文來(lái)自:http://blog.csdn.net/farawayplace613/archive/2008/09/10/2910527.aspx
相關(guān)文章
vs2010根據(jù)字符串內(nèi)容添加斷點(diǎn)的方法介紹
這篇文章介紹了vs2010根據(jù)字符串內(nèi)容添加斷點(diǎn)的方法,有需要的朋友可以參考一下2013-08-08WebForm獲取checkbox選中的值(幾個(gè)簡(jiǎn)單的示例)
WebForm中用checkbox的地方挺多的,下面寫(xiě)了幾個(gè)簡(jiǎn)單的例子,方便以后學(xué)習(xí)使用2014-07-07ASP .NET調(diào)用javascript中Response.Write和ClientScript.RegisterSta
最近在用ASP .NET的code behind 調(diào)用javascript中發(fā)現(xiàn)Response.Write不能拿到form的值,而ClientScript.RegisterStartupScript可以。2010-12-12asp.net基于Web Service實(shí)現(xiàn)遠(yuǎn)程上傳圖片的方法
這篇文章主要介紹了asp.net基于Web Service實(shí)現(xiàn)遠(yuǎn)程上傳圖片的方法,涉及asp.net調(diào)用Web Service的文件流操作與文件傳輸實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-12-12使用AjaxPro.Net框架實(shí)現(xiàn)在客戶端調(diào)用服務(wù)端的方法
AjaxPro.Net是一個(gè)優(yōu)秀的.net環(huán)境下的Ajax框架,用法很簡(jiǎn)單,可以查閱相關(guān)資料,本文檔是一個(gè)簡(jiǎn)單的實(shí)例講述使用AjaxPro的幾個(gè)關(guān)鍵點(diǎn)。2011-02-02.Net Core3 用Windows 桌面應(yīng)用開(kāi)發(fā)Asp.Net Core網(wǎng)站
這篇文章主要介紹了.Net Core3 用Windows 桌面應(yīng)用開(kāi)發(fā)Asp.Net Core網(wǎng)站,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01