C # use Microsoft's Visual Studio International pack class library to extract the first letter of Chinese pinyin

Source: Internet
Author: User

This article from: http://www.cnblogs.com/yazdao/archive/2011/06/04/2072488.html

After a prompt from a netizen yesterday, the method for extracting Chinese characters and pinyin can be applied to a Microsoft class library Visual Studio International pack. Today, I tried it and it is actually easy to use! The following describes the application methods:

Download Visual Studio International pack 1.0. Official Website:Http://www.microsoft.com/downloads/zh-cn/details.aspx? Familyid = 44cac7f0-633b-477d-aed2-99aee642fc10 & displaylang = ZH-CN. After downloading, decompress the package and create seven MSI installation files. MSI is a Chinese pinyin component, chtchsconv. MSI is a traditional and simplified conversion component. you can install these two MSI (the default installation directory on the x86 operating system is c: \ Program Files \Microsoft Visual Studio International pack\). After the installation is complete, you must 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.

 

After completing the above work, the application method is very simple. See belowCode:

 

 

 

Using Microsoft. International. converters. pinyinconverter; // import pinyin coherence

Namespace webapplication2
{
Public class class1
{
/// <Summary>
/// Convert Chinese characters to PinYin
/// </Summary>
/// <Param name = "str"> Chinese characters </param>
/// <Returns> full competition </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 pinyin alphabet
/// </Summary>
/// <Param name = "str"> Chinese characters </param>
/// <Returns> initial letter </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;
}
}
}

Copy code

 

 

 

Call method: (pay attention to first reference)

 

Getpinyin ("Wind shadows"); // obtain the full spelling
Getfirstpinyin ("wind shadow"); // get the first letter

 

 

 

Is it very simple? With this class library, it is much easier! Then I will try to add some methods for changing the traditional Chinese Style. Some time may be used:

 

Pilot Import

 

Using Microsoft. International. converters. traditionalchinesetosimplifiedconverter;

 

/// <Summary>
/// Convert simplified to traditional
/// </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 Chinese
/// </Summary>
/// <Param name = "str"> traditional Chinese character </param>
/// <Returns> simplified Chinese character </returns>
Public static string get Simplified (String Str)
{
String r = string. empty;
R = chineseconverter. Convert (STR, chineseconversiondirection. traditionaltosimplified );
Return R;
}

Copy code

 

Function overview of this class library

 

Microsoft Visual Studio International pack 1.0 provides the following features:

    • East Asia numeric formatting library-converts lowercase numeric strings into uppercase numeric strings in simplified Chinese, traditional Chinese, Japanese, and Korean.
    • Japanese Kana conversion library-supports converting a Japanese alias (Kana) to another Japanese character.
    • Japanese text alignment library-an alignment pattern exclusive to Japanese.
    • 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 that are automatically 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. The component also contains a Visual Studio integrated development scene plug-in (add-in) support conversion between simplified and Traditional Chinese 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 supports annotation for the general type, any object that implements the ienumerable interface can be annotated by string type and generic instance. In order to simplify the complex annotation string fighting strength, we designed the fighting strength types supporting various Japanese fighting options.
          • Some generic classes use generics to enable phonetic injection for a enumerated type.
          • Some classes with special goals use the above generic to enable certain types of sound injection for a string.
          • In particular, some stringannotation classes use the above generic to enable a string to be voiced, including the parsing and pattern functions.
          • A fighting tool class that applies the above classes to implement fighting strings.
          • A data layout that implements ienumerable <string>, divides a string into the 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 applies Ruby labels.
      • The Chinese Text alignment class library and textbox controls contain the winform and WPF textbox controls supporting 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 actively complete winform and WPF, and a class library that allows developers to easily add sensor input methods to standard controls and actively complete functions.
      • Korean auto complete class library and ComboBox controls include the winform and WPF ComboBox controls that support the awareness of Korean input methods, and a class library that allows developers to easily add sensor input methods to standard controls and actively complete functions.
      • Numeric formatting class library contains five types of words that support the digital format into the text class, and Version 2.0 supports the pattern of Arabic numerals as Arabic text.

      It can be seen that this class library is very practical in developing international laws.

Related Article

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.