Two Methods for simplified Chinese conversion using. net

Source: Internet
Author: User

Method 1: Call the class library of VB. NET.

Reference Microsoft. VisualBasic. dll.

Traditional Chinese = Microsoft. VisualBasic. Strings. strconv (Simplified Chinese, Microsoft. VisualBasic. vbstrconv. traditionalchinese, 0 );

 

Method 2: Use the Visual Studio International Pack component provided by Microsoft.

First download Visual Studio International pack 1.0, official: http://www.microsoft.com/downloads/zh-cn/details.aspx? Familyid = 44cac7f0-633b-477d-aed2-99aee642fc10 & displaylang = ZH-CN. After the download is complete, decompress the package and you will find seven MSI installation files. chspinyinconv. MSI is a Chinese pinyin component, and chtchsconv. MSI is a simplified and simplified conversion component. you can install these two MSI files.
(The default installation directory on the x86 operating system is c: \ Program Files \Microsoft Visual Studio International pack\). After the installation is complete, you need to add references in vs to reference them separately:C: \ Program Files \ Microsoft Visual Studio International pack \ Simplified Chinese pin-yin conversion Library(Pinyin) andC: \ Program Files \ Microsoft
Visual Studio International pack \ traditional Chinese to simplified Chinese conversion library and add-in tool
(Simple and easy to use.

Simplified Chinese conversion example

Using Microsoft. International. converters. traditionalchinesetosimplifiedconverter;

/// <Summary> /// convert simplified to traditional Chinese /// </Summary> /// <Param name = "str"> simplified Chinese character </param> /// <returns> traditional Chinese characters </returns> Public static string gettraditional (string Str) {string r = string. empty; r = chineseconverter. convert (STR, chineseconversiondirection. simplifiedtotraditional); return r ;} /// <summary> /// convert traditional Chinese to simplified // </Summary> /// <Param name = "str"> traditional Chinese </param> // <returns> simplified Chinese character </returns> Public static string getsimplified (string Str) {string r = string. empty; r = chineseconverter. convert (STR, chineseconversiondirection. traditionaltosimplified); return r ;}

Example of how to get pinyin from Chinese characters:

Using Microsoft. international. converters. pinyinconverter; // import pinyin-related namespace webapplication2 {public class class1 {// <summary> // convert Chinese characters to PinYin /// </Summary> /// <Param name =" str "> Chinese Character </param> /// <returns> full spelling </returns> Public static string getpinyin (string Str) {string r = string. empty; foreach (char OBJ in Str) {try {chinesechar = new chinesechar (OBJ); string T = chinesechar. pinyins [0]. tostring (); R + = T. substring (0, T. length-1);} catch {R + = obj. tostring () ;}} return r ;} /// <summary> // convert Chinese characters to the first letter of the alphabet /// </Summary> /// <Param name = "str"> Chinese characters </param> /// <returns> initial </returns> Public static string getfirstpinyin (string Str) {string r = string. empty; foreach (char OBJ in Str) {try {chinesechar = new chinesechar (OBJ); string T = chinesechar. pinyins [0]. tostring (); R + = T. substring (0, 1);} catch {R + = obj. tostring () ;}} return r ;}}}

Function overview of this class library

Microsoft Visual Studio International pack 1.0 provides the following features:

  • East Asia numeric formatting library-supports formatting lowercase numeric strings into uppercase numeric strings in simplified Chinese, traditional Chinese, Japanese, and Korean.
  • Japanese Kana conversion library-supports converting Japanese Kana to another Japanese character.
  • Japanese text alignment library-supports a Japanese-specific alignment format.
  • The Japanese Yomi auto-completion library-Class Library supports the input of the daily input method and an example of a text box control.
  • Korean auto complete Textbox Control-supports smart sensing of Korean input methods and text box controls automatically completed by input.
  • Simplified Chinese pin-yin conversion library-supports obtaining common attributes of simplified Chinese characters, such as pinyin, polyphonic words, Homophone Words, and strokes.
  • Traditional Chinese to simplified Chinese conversion library and add-in tool-supports conversion between simplified and Traditional Chinese. This component also contains a plug-in (add-in) in the integrated development environment of Visual Studio that supports conversion between simplified and Traditional Chinese resource files.

     

    Visual Studio International Feature Pack 2.0 is an extension of version 1.0, including a set of controls and class libraries:

    • The yomigana framework contains class libraries and controls.

      • Class Library: The yomigana class library allows you to add yomigana to the string type, and also supports annotation for the general type, any object that implements the ienumerable interface can be annotated by string type and generic instance. To simplify the comparison of complex annotation strings, a comparison type that supports various Japanese comparison options is designed.

        • Some generic classes use generics to enable injection for an enumerable type.
        • For special purposes, you can use the generic above to enable certain types of sound injection for a string.
        • For special purposes, the stringannotation class uses the above generic to enable a string to be voiced, including the parsing and formatting functions.
        • A comparator class that compares strings.
        • A Data Structure that implements ienumerable <string>, divides a string into enumerated string segments, and outputs it using ienumerator <string>.
      • Controls:
        • The enhanced ajax/WPF/winform text box (textbox) control is used to capture pronunciation based on user input.
        • An enhanced ASP. NET label control that uses Ruby labels.
    • The Chinese Text alignment class library and textbox controls contain the winform and WPF textbox controls that support simplified Chinese Text alignment, and a class library that helps developers easily align and display strings according to Chinese text.
    • Chinese auto complete class library and textbox controls include textbox controls that support simplified Chinese and Traditional Chinese Input Methods and automatically complete winform and WPF, and a class library that allows developers to easily add sensor input methods to standard controls and automatically complete functions.
    • Korean auto complete class library and ComboBox controls include the winform and WPF ComboBox controls that support awareness of Korean input methods and are automatically completed, and a class library that allows developers to easily add sensor input methods to standard controls and automatically complete functions.
    • Numeric formatting class library contains classes that support formatting numbers in five languages into texts. Version 2.0 supports formatting Arabic numerals into Arabic texts.

     

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.