asp.net中简体转繁体实现代码

所属分类: 网络编程 / ASP.NET 阅读数: 1633
收藏 0 赞 0 分享
我还是直接贴例子在说明一下吧:
复制代码 代码如下:

//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;
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;
}
}

注意了,上面下载地下载的是VS2008创建的项目.
可能需要你把代码拷贝到你自己的环境中。下载中重要的是Encode.dll。
哈哈,简单吧,就两句就搞定了简繁体的转换。
作者:程呈
原文来自:http://blog.csdn.net/farawayplace613/archive/2008/09/10/2910527.aspx
更多精彩内容其他人还在看

ASP.NET比较常用的26个性能优化技巧

这篇文章主要给大家介绍asp.net中比较常用的26个性能优化技巧,主要设计到asp.net中常用的26个性能优化方面的内容,对于asp.net中常用的26个性能优化技巧感兴趣的朋友可以参考下本篇文章
收藏 0 赞 0 分享

区分ASP.NET中get方法和post方法

我们都知道,get是从服务器上获取数据,post是向服务器上传数据。本文主要介绍ASP.NET中get方法和post方法的区别,需要的朋友可以参考下
收藏 0 赞 0 分享

SQL Server数据库连接 Web.config如何配置

以下的文章主要描述的是Web.config正确配置SQL Server数据库连接的实际擦步骤。我们以图文结合的方式对其有个更好的说明,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP.NET MVC5实现文件上传与地址变化处理(5)

这篇文章主要介绍了ASP.NET MVC5实现文件上传与地址变化处理,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

ASP.NET MVC5网站开发概述(一)

这篇文章主要内容是ASP.NET MVC5网站开发实践的整体概述,分析了开发环境、使用的技术以及项目的整体结构,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

asp.net中GridView数据鼠标移入显示提示信息

本篇文章给大家介绍在asp.net中gridview数据鼠标移入显示提示信息,需要的朋友可以参考下本文
收藏 0 赞 0 分享

一个简单MVC5 + EF6示例分享

本文小编跟大家分享了一个简单MVC5 + EF6示例,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

ASP.NET MVC5网站开发项目框架(二)

这篇文章主要介绍了ASP.NET MVC5网站开发项目框架,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

ASP.NET MVC5 网站开发框架模型、数据存储、业务逻辑(三)

上次搭建好了项目框架,但还是觉得不太对劲,后来才想起来没有对开发目标进行定位,这个小demo虽然不用做需求分析,但是要实现什么效果还得明确。后来想了一下就做个最简单的网站,目标定为小公司进行展示用的网站。功能有显示用的文章功能,咨询留言,评论等
收藏 0 赞 0 分享

ASP.NET MVC 5之邮件服务器与客户端

这篇文章主要介绍了ASP.NET MVC5邮件服务器与客户端,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多