欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C# 中文簡(jiǎn)體轉(zhuǎn)繁體實(shí)現(xiàn)代碼

 更新時(shí)間:2013年02月19日 11:11:17   作者:  
C# 中文簡(jiǎn)體轉(zhuǎn)繁體實(shí)現(xiàn)代碼,需要的朋友可以參考一下

方法一:

復(fù)制代碼 代碼如下:

/// <summary>
 /// 中文字符工具類
 /// </summary>
 private const int LOCALE_SYSTEM_DEFAULT = 0x0800;
 private const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;
 private const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;

 [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
 private static extern int LCMapString(int Locale, int dwMapFlags, string lpSrcStr, int cchSrc, [Out] string lpDestStr, int cchDest);

      /// <summary>
      /// 將字符轉(zhuǎn)換成簡(jiǎn)體中文
      /// </summary>
      /// <param name="source">輸入要轉(zhuǎn)換的字符串</param>
      /// <returns>轉(zhuǎn)換完成后的字符串</returns>
      public static string ToSimplified(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;
      }

     /// <summary>
     /// 講字符轉(zhuǎn)換為繁體中文
     /// </summary>
     /// <param name="source">輸入要轉(zhuǎn)換的字符串</param>
     /// <returns>轉(zhuǎn)換完成后的字符串</returns>
     public static string ToTraditional(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;
     }


  調(diào)用上面的ToTraditiona方法就OK了~另外的那個(gè)一樣的使用方法~
方法二:(推薦)
①在解決方案管理器中對(duì)應(yīng)的文件夾右擊“添加引用”----選擇.net引用下的Microsoft.VisualBasic;
②在你要實(shí)現(xiàn)轉(zhuǎn)換功能的aspx.cs文件中添加命名空間:using Microsoft.VisualBasic
③ 通過下面的方法可以直接實(shí)現(xiàn)轉(zhuǎn)換,很方便吧!一句話就可以了~所以推薦這個(gè)方法
復(fù)制代碼 代碼如下:

 string   s   =   "繁體";
         s   =   Strings.StrConv(s,   VbStrConv.Wide,   0);   //   半角轉(zhuǎn)全角
         s   =   Strings.StrConv(s,   VbStrConv.TraditionalChinese,   0);   //   簡(jiǎn)體轉(zhuǎn)繁體
         s   =   Strings.StrConv(s,   VbStrConv.ProperCase ,   0);   //   首字母大寫
         s   =   Strings.StrConv(s,   VbStrConv.Narrow ,   0);   //   全角轉(zhuǎn)半角
         s   =   Strings.StrConv(s,   VbStrConv.SimplifiedChinese,   0);   //   繁體轉(zhuǎn)簡(jiǎn)體

相關(guān)文章

最新評(píng)論