asp.net中简体转繁体实现代码
程序员文章站
2024-03-08 19:56:40
我还是直接贴例子在说明一下吧: 复制代码 代码如下: //form1.cs using system; using system.collections.generic;...
我还是直接贴例子在说明一下吧:
//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。
哈哈,简单吧,就两句就搞定了简繁体的转换。
作者:程呈
原文来自:
复制代码 代码如下:
//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。
哈哈,简单吧,就两句就搞定了简繁体的转换。
作者:程呈
原文来自:
上一篇: asp.net 生成缩略图代码