汉字繁简转换,取拼音、笔画、读音

2009年3月31日,微软发布了 Microsoft Visual Studio International Pack 1.0 SR1。Visual Studio International Pack 包含一组类库,该类库扩展了.NET Framework对全球化软件开发的支持。使用该类库提供的类,.NET 开发人员可以更方便的创建支持多文化多语言的软件应用。下载地址是:http://www.microsoft.com/downloads/details.aspx?FamilyID=44cac7f0-633b-477d-aed2-99aee642fc10&DisplayLang=zh-cn

该软件包1.0版提供下面七个组件以增强.NET Framework对全球化软件应用开发的支持。

East Asia Numeric Formatting Library - 支持将小写的数字字符串格式化成简体中文,繁体中文,日文和韩文的大写数字字符串。
Japanese Kana Conversion Library - 支持将日文假名(Kana)转化为另一种日文字符。
Japanese Text Alignment Library - 支持日文特有的一种对齐格式。
Japanese Yomi Auto-Completion Library - 类库支持感知日文输入法的输入自动完成和一个文本框控件的示例。
Korean Auto Complete TextBox Control - 支持韩文输入法的智能感知和输入自动完成的文本框控件。
Simplified Chinese Pin-Yin Conversion Library - 支持获取简体中文字符的常用属性比如拼音,多音字,同音字,笔画数。
Traditional Chinese to Simplified Chinese Conversion Library and Add-In Tool - 支持简繁体中文之间的转换。该组件还包含一个Visual Studio集成开发环境中的插件(Add-in)支持简繁体中文资源文件之间的转换。

 

其他方式实现繁简转换

方法一:

可以利用VB.NET中的StrConv方法来实现,

需要先添加对Microsoft Visual Basic.net runtime.dll程序集的引用

//繁体转简体 
  MessageBox.Show(Microsoft.VisualBasic.Strings.StrConv("张三",Microsoft.VisualBasic.VbStrConv.SimplifiedChinese,0));   

 //简体转繁体  
  MessageBox.Show(Microsoft.VisualBasic.Strings.StrConv("张三",Microsoft.VisualBasic.VbStrConv.TraditionalChinese,0)); 

 

方法二:

单纯的使用C#也可以实现,方法如下:
  System.Text.Encoding   gb2312=System.Text.Encoding.GetEncoding("gb2312");  
  System.Text.Encoding   big5=System.Text.Encoding.GetEncoding("big5");  
  string   s="这是一个汉字转换测试";  
  byte[]   bGb2312=gb2312.GetBytes(s);  
  byte[]   bBig5=System.Text.Encoding.Convert(gb2312,big5,bGb2312);  
string result=big5.GetString(bBig5);

 

方法三:

public static class ChineseStringConverter
{
     internal const int LOCALE_SYSTEM_DEFAULT = 0x0800;
     internal const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;
     internal const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;
     [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
     internal static extern int LCMapString(int Locale, int dwMapFlags, string lpSrcStr, int cchSrc, [Out] string lpDestStr, int cchDest);
       public static string TraditionalToSimplified(string source)
      {
             String target = new String(' ', source.Length);
             int ret = LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_SIMPLIFIED_CHINESE, source, source.Length, target, source.Length);

             return target;
      }
       public static string SimplifiedToTraditional(string source)
      {
              String target = new String(' ', source.Length);
              int ret = LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_TRADITIONAL_CHINESE, source, source.Length, target, source.Length);
              return target;
       }
}

posted @ 2012-11-03 21:34  杂货匠工  Views(508)  Comments(0)    收藏  举报