Microsoft Visual Studio International Pack 1.0 SR1

from: http://www.microsoft.com/downloads/details.aspx?FamilyID=44cac7f0-633b-477d-aed2-99aee642fc10&DisplayLang=zh-cn

快速描述

Visual Studio International Pack 包含一组类库,该类库扩展了.NET Framework对全球化软件开发的支持。使用该类库提供的类,.NET 开发人员可以更方便的创建支持多文化多语言的软件应用。SR1 包含对 Japanese Kana Conversion Library 和 Japanese Yomi Auto-Completion Library 中软件缺陷的修正。

概述

Visual Studio International Pack 包含一组类库,该类库扩展了.NET Framework对全球化软件开发的支持。使用该类库提供的类,.NET 开发人员可以更方便的创建支持多文化多语言的软件应用。 该软件包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)支持简繁体中文资源文件之间的转换。


发布的SR1中修正了 Japanese Kana Conversion Library 和 Japanese Yomi Auto-Completion Library 中的软件缺陷, 其他库中没有改动。

系统要求

  • 支持的操作系统: Windows Server 2003 R2 (32-Bit x86); Windows Vista Service Pack 1; Windows XP Service Pack 3
  • 所需软件: Microsoft Visual Studio 2005 或者 Microsoft Visual Studio 2008, Microsoft .NET Framework 2.0, Microsoft Office 2007 (使用Traditional Chinese to Simplified Chinese Conversion Library and Add-In Tool 进行简繁体中文之间的转换时需要安装该组件)

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.International.Converters.TraditionalChineseToSimplifiedConverter;
using Microsoft.International.Converters.PinYinConverter;
using Microsoft.International.Formatters;
using System.Globalization;


/*
 * Microsoft Visual Studio International Feature Pack 2.0
 https://www.microsoft.com/zh-cn/download/details.aspx?id=18970
 * C:\Program Files\Microsoft Visual Studio International Feature Pack 2.0\
 * 
 Microsoft Visual Studio International Pack 1.0 SR1
 * https://www.microsoft.com/zh-cn/download/confirmation.aspx?id=15251
 * 安裝的位置:
 * C:\Program Files\Microsoft Visual Studio International Pack\Simplified Chinese Pin-Yin Conversion Library(拼音)下
 * C:\Program Files\Microsoft Visual Studio International Pack\Traditional Chinese to Simplified Chinese Conversion Library and Add-In Tool(繁简互转)
 * C:\Program Files\Microsoft Visual Studio International Pack\East Asia Numeric Formatting Library
 */

namespace Geovin.Du.Commn
{

    /// <summary>
    /// 2017-05-11
    /// </summary>
    public class InternationalChangeChinese
    {

         /// <summary> 
        /// 汉字转化为拼音
        /// </summary> 
        /// <param name="str">汉字</param> 
        /// <returns>全拼</returns> 
        public static string GetPinyin(string str)
        {
            string r = string.Empty;
            foreach (char obj in str)
            {
                try
                {
                    ChineseChar chineseChar = new ChineseChar(obj);
                    string t = chineseChar.Pinyins[0].ToString();
                    r += t.Substring(0, t.Length - 1);
                }
                catch
                {
                    r += obj.ToString();
                }
            }
            return r;
        }

        /// <summary> 
        /// 汉字转化为拼音首字母
        /// </summary> 
        /// <param name="str">汉字</param> 
        /// <returns>首字母</returns> 
        public static string GetFirstPinyin(string str)
        {
            string r = string.Empty;
            foreach (char obj in str)
            {
                try
                {
                    ChineseChar chineseChar = new ChineseChar(obj);
                    string t = chineseChar.Pinyins[0].ToString();
                    r += t.Substring(0, 1);
                }
                catch
                {
                    r += obj.ToString();
                }
            }
            return r;
       }
        /// <summary> 
        /// 简体转换为繁体
        /// </summary> 
        /// <param name="str">简体字</param> 
        /// <returns>繁体字</returns> 
        public static string GetTraditional(string str)
        {
            string r = string.Empty;
            r = ChineseConverter.Convert(str, ChineseConversionDirection.SimplifiedToTraditional);
            return r;
        }
        /// <summary> 
        /// 繁体转换为简体
        /// </summary> 
        /// <param name="str">繁体字</param> 
        /// <returns>简体字</returns> 
        public static string GetSimplified(string str)
        {
            string r = string.Empty;
            r = ChineseConverter.Convert(str, ChineseConversionDirection.TraditionalToSimplified);
            return r;
        }

        /// <summary>
        /// 将数字转换为小写(十二亿三千四百五十六万七千八百九十点四五)
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static string GetSimplifiedNumber(decimal iNum)
        {
            return string.Format(new Microsoft.International.Formatters.EastAsiaNumericFormatter(), "{0:Ln}", iNum);
        }

        /// <summary>
        /// 将数字转换为大写简体中文(拾贰亿叁仟肆佰伍拾陆万柒仟捌佰玖拾点肆伍)
        /// 
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static string GetTraditionalNumber(decimal iNum)
        {
            return string.Format(new Microsoft.International.Formatters.EastAsiaNumericFormatter(), "{0:L}", iNum);
        }
        /// <summary>
        /// 将数字转换为货币(拾贰亿叁仟肆佰伍拾陆万柒仟捌佰玖拾点肆伍)
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static string GetCurrencyNumber(decimal iNum)
        {
            return string.Format(new Microsoft.International.Formatters.EastAsiaNumericFormatter(), "{0:Lc}", iNum);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static string GetChineseTraditionalNumber(decimal iNum)
        {
            return Microsoft.International.Formatters.EastAsiaNumericFormatter.FormatWithCulture("L", iNum, null, new CultureInfo("zh-TW"));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="iNum"></param>
        /// <returns></returns>
        public static string GetChineseSimplifiedNumber(decimal iNum)
        {
            return Microsoft.International.Formatters.EastAsiaNumericFormatter.FormatWithCulture("L", iNum, null, new CultureInfo("zh-CN"));
        }
        /// <summary>
        /// 日文
        /// </summary>
        /// <param name="iNum"></param>
        /// <returns></returns>
        public static string GetJapaneseNumber(decimal iNum)
        {
            return Microsoft.International.Formatters.EastAsiaNumericFormatter.FormatWithCulture("L", iNum, null, new CultureInfo("Ja"));
        }


    }
}

  

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//添加 Microsoft Visual Basic.NET Runtime 引用。
using Microsoft.VisualBasic;
using System.IO;
using System.Runtime.InteropServices;



namespace Geovin.Du.Commn
{

    /// <summary>
    /// VB 繁简换
    /// 2017-05-11
    /// </summary>
    public class VBChangeChinese
    {

        /// <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>
        /// 将字符转换成简体中文
        /// </summary>
        /// <param name="source">输入要转换的字符串</param>
        /// <returns>转换完成后的字符串</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>
        /// 讲字符转换为繁体中文
        /// </summary>
        /// <param name="source">输入要转换的字符串</param>
        /// <returns>转换完成后的字符串</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;
        }
        /// <summary>
        /// 将字符串转换为简体中文
        /// </summary>
        public static string ToSimplifiedChinese(string s)
        {
            return Strings.StrConv(s, VbStrConv.SimplifiedChinese, 0);
        }

        /// <summary>
        /// 将字符串转换为繁体中文
        /// </summary>
        public static string ToTraditionalChinese(string s)
        {
            return Strings.StrConv(s, VbStrConv.TraditionalChinese, 0);
        }
        /// <summary>
        ///  半角转全角 
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static string ToWide(string s)
        {
            return Strings.StrConv(s, VbStrConv.Wide, 0);   //   半角转全角 
        }
        /// <summary>
        /// 全角转半角 
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static string ToNarrow(string s)
        {
            return Strings.StrConv(s, VbStrConv.Narrow, 0);   //   全角转半角 
        }
        /// <summary>
        /// 首字母大写
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static string ToProperCase(string s)
        {
            return Strings.StrConv(s, VbStrConv.ProperCase, 0);   //   首字母大写 
        }

        /// <summary>
        /// 将文件转换为简体中文
        /// </summary>
        /// <param name="filename">源文件名</param>
        /// <param name="outFilename">目标文件名</param>
        public static void ToSimplifiedChinese(string filename, string outFilename)
        {
            StreamReader r = new StreamReader(filename, Encoding.GetEncoding("gb2312"));
            StreamWriter w = new StreamWriter(outFilename, false, Encoding.GetEncoding("gb2312"));
            try
            {
                w.Write(Strings.StrConv(r.ReadToEnd(), VbStrConv.SimplifiedChinese, 0));
                w.Flush();
            }
            finally
            {
                w.Close();
                r.Close();
            }
        }

        /// <summary>
        /// 将文件转换为繁体中文
        /// </summary>
        /// <param name="filename">源文件名</param>
        /// <param name="outFilename">目标文件名</param>
        public static void ToTraditionalChinese(string filename, string outFilename)
        {
            StreamReader r = new StreamReader(filename, Encoding.GetEncoding("gb2312"));
            StreamWriter w = new StreamWriter(outFilename, false, Encoding.GetEncoding("gb2312"));
            try
            {
                w.Write(Strings.StrConv(r.ReadToEnd(), VbStrConv.TraditionalChinese, 0));
                w.Flush();
            }
            finally
            {
                w.Close();
                r.Close();
            }
        }
        /// <summary>  
        /// 简体转繁体  
        /// </summary>  
        /// <param name="converText">转换内容</param>  
        /// <returns>繁体</returns>  
        public static string ConvertBig5(string converText)
        {
            converText = Microsoft.VisualBasic.Strings.StrConv(converText, Microsoft.VisualBasic.VbStrConv.TraditionalChinese, new System.Globalization.CultureInfo("zh-cn").LCID);
            Encoding eBig5 = Encoding.GetEncoding(950);
            byte[] bBig5 = eBig5.GetBytes(converText);
            converText = eBig5.GetString(bBig5);
            return converText;
        }

        /// <summary>  
        /// 繁体转简体  
        /// </summary>  
        /// <param name="converText">转换内容</param>  
        /// <returns>简体</returns>  
        public static string ConvertGb2312(string converText)
        {
            converText = Microsoft.VisualBasic.Strings.StrConv(converText, Microsoft.VisualBasic.VbStrConv.SimplifiedChinese, new System.Globalization.CultureInfo("zh-cn").LCID);
            Encoding eGb2312 = Encoding.GetEncoding(936);
            byte[] gb2312 = eGb2312.GetBytes(converText);
            converText = eGb2312.GetString(gb2312);
            return converText;
        }

        /// <summary>  
        /// 将繁体乱码转繁体(已经是big5编码,在数据传输的过程中,被转成了UTF8,导致乱码)  
        /// </summary>  
        /// <param name="o">big5乱码</param>  
        /// <param name="isConvert">是否要转换</param>  
        /// <returns></returns>  
        public static string ConvertBig5(object o, bool isConvert)
        {
            if (o == null) return string.Empty;
            if (!isConvert) return o.ToString();
            string result = o.ToString();
            try
            {
                byte[] buffer = Encoding.Default.GetBytes(o.ToString());
                result = Encoding.GetEncoding("big5").GetString(buffer);
            }
            catch(Exception ex) 
            {
                ex.Message.ToString();
            }
            return result;
        }  
    }
}

  

       /// <summary>
        /// 所有拼音 MENG1 的汉字第几声调的
        /// </summary>
        /// <param name="pinyin">MENG1</param>
        /// <param name="strout">輸所有字的字符串</param>
        /// <returns></returns>
        public static List<string> GetPinyins(string pinyin,out string strout)
        {

            //ChineseChar.GetStrokeNumber('孟')); 筆畫數
            StringBuilder s = new StringBuilder();
            List<string> str = new List<string>();
            char[] chineseChars = ChineseChar.GetChars(pinyin);
            foreach(char cstr in chineseChars)
            {
                str.Add(cstr.ToString());
                s.Append(cstr.ToString());
            }
            strout=s.ToString();
            return str;
        }
        /// <summary>
        /// 是否是多音字的所有拼音
        /// </summary>
        /// <param name="word">孟</param>
        /// <returns></returns>
        public static List<string> GetPinyinmore(char word)
        {
            List<string> more = new List<string>();
            ChineseChar chineseChar = new ChineseChar(word);
            if (chineseChar.IsPolyphone) //是否多音字
            {
                ReadOnlyCollection<string> pinyin = chineseChar.Pinyins;
                foreach (string pin in pinyin)
                {
                    more.Add(pin);
                }
            }
            return more;
        }

  

posted @ 2009-12-06 12:42  ®Geovin Du Dream Park™  阅读(715)  评论(1编辑  收藏  举报