最近到了台企,什么都要用繁体的。

开发中也遇到了简繁体转换的问题。

这里和朋友们分享一下用.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;
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://www.ttkz.com也正想用上。

转载于:https://www.cnblogs.com/kaizhang/archive/2010/03/10/1682650.html

在ne中分析贱谈.net中简体转繁体相关推荐

  1. matlab中分析数据规律,matlab中数据的统计描述和分析

    少年易学老难成,一寸光阴不可轻 - 百度文库 122 第十章 数据的统计描述和分析 数理统计研究的对象是受随机因素影响的数据,以下数理统计就简称统计,统计是以概率论为基础的一门应用学科. 数据样本少则 ...

  2. java中hashcode_浅谈Java中的Hash值

    1.Hash值有什么用? HashMap.HashTable.HashSet,所以涉及到使用Hash值进行优化存储的地方,都会用到HashCode.HashCode是Key,这种计算为提高计算的性能. ...

  3. python中webdriver_浅谈python中selenium库调动webdriver驱动浏览器的实现原理

    最近学web自动化时用到selenium库,感觉很神奇,遂琢磨了一下,写了点心得. 当我们输入以下三行代码并执行时,会发现新打开了一个浏览器窗口并访问了百度首页,然而这是怎么做到的呢? 1 from ...

  4. python中bs4_浅谈Python中的bs4基础

    安装 在命令提示符框中直接输入pip install beautifulsoup4 介绍 beautifulsoup是python的一个第三方库,和xpath一样,都是用来解析html数据的. 引入 ...

  5. python语句中ord_浅谈Python中chr、unichr、ord字符函数之间的对比

    ord是unicode ordinal的缩写,即编号 chr是character的缩写,即字符 ord和chr是互相对应转换的. 但是由于chr局限于ascii,长度只有256,于是又多了个unich ...

  6. php中 br什么意思,HTML_html中br和br/的区别介绍,answer from stackflow: Simply br - phpStudy...

    html中br和br/的区别介绍 answer from stackflow: Simply is sufficient. The other forms are there for compatib ...

  7. python tkinter 中文文档_Python实现中文文档的简体与繁体互相转换

    封面图片:<Python程序设计实验指导书>,董付国编著,清华大学出版社,2019.4 ============= 本文重点是一个第三方工具的使用,首先从下面的地址下载这两个文件并存放于程 ...

  8. Python实现中文文档的简体与繁体互相转换

    本文重点是一个第三方工具的使用,首先从下面的地址下载这两个文件并存放于程序文件所在文件夹. https://raw.githubusercontent.com/skydark/nstools/mast ...

  9. 浅谈计算机教学的现状分析,浅谈中职计算机专业教学的现状与对策

    好文网为大家准备了关于浅谈中职计算机专业教学的现状与对策的文章,好文网里面收集了五十多篇关于好浅谈中职计算机专业教学的现状与对策好文,希望可以帮助大家.更多关于浅谈中职计算机专业教学的现状与对策内容请 ...

最新文章

  1. [Linux]安装node.js
  2. pdf压缩工具_PDF文件过大如何缩小,几步教你完成压缩
  3. 【深度学习】详解集成学习的投票和Stacking机制
  4. [导入]silverlight 2.0希伯来语及阿拉伯语的support.zip(344.42 KB)
  5. C/C++杂记:虚函数的实现的基本原理 虚函数表
  6. 关于jquery调用webservice的一些感想
  7. html中name和id的区别 [ZT]
  8. NET Core的代码安全分析工具 - Security Code Scan
  9. STL之函数对象和谓词
  10. Ubuntu服务器修复,ubuntu – 服务器攻击,如何修复它
  11. 面向对象程序的设计模式
  12. 深度学习笔记_损失函数softmax和SVM
  13. 解决:网络风暴引起的无法ping通
  14. USACO 土地购买
  15. 蓝牙耳机连接笔记本电脑音量直接爆棚
  16. 【转】python技术博客
  17. MyBatis - 官方网址
  18. 用Moment.js 计算两个时间直接的间隔
  19. 水果店怎样开业吸引人流量,水果店怎样开业吸引人
  20. 电脑变慢,4K对齐来解决

热门文章

  1. sql中的遇到的有问题的
  2. coreleft函数
  3. 操作系统动态库调用过程
  4. composer查看当前镜像取消_国内全量镜像大全
  5. MATLAB读取txt文件的数据
  6. 一键对频对讲机好吗_挑战传统,新型对讲机展现独特一面--极蜂智能网络对讲机...
  7. 教你玩转CSS 分组选择器和嵌套选择器
  8. ubuntu vim php配置文件在哪,ubuntu vim的配置文件在哪
  9. java调用kettle例子_Kettle API - Java调用示例
  10. canvas1:简单介绍、开始使用、画直线+虚线