在项目中先引用Encode.dll 下面是下载地址:
1、html页面代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="简繁转换.aspx.cs" Inherits="ASP.NET_语言基础.简繁转换" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtjian" TextMode="MultiLine" Width="500px" Height="200px" runat="server"></asp:TextBox><br /> <asp:Button ID="btnjtof" runat="server" Text="简体转繁体" onclick="btnjtof_Click" /> <asp:Button ID="btnftoj" runat="server" Text="繁体转简体" onclick="btnftoj_Click" /> <br /> <asp:TextBox ID="txtfan" TextMode="MultiLine" Width="500px" Height="200px" runat="server"></asp:TextBox> </div> </form> </body> </html>
2、后台.cs代码
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using EncodeMy; namespace ASP.NET_语言基础 { public partial class 简繁转换 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnjtof_Click(object sender, EventArgs e) { EncodeRobert er = new EncodeRobert(); txtfan.Text = er.SCTCConvert(ConvertType.Simplified, ConvertType.Traditional, txtjian.Text); } protected void btnftoj_Click(object sender, EventArgs e) { EncodeRobert er = new EncodeRobert(); txtfan.Text = er.SCTCConvert(ConvertType.Traditional, ConvertType.Simplified, txtjian.Text); } } }
3、效果图
想深入了解的请看:http://www.cnblogs.com/byvar/p/4012861.html
以下是微软的转换:
http://www.microsoft.com/zh-cn/download/details.aspx?id=18970
http://www.microsoft.com/zh-cn/download/details.aspx?id=15251