Kanji Processing Components

Source: Internet
Author: User

Sometimes the project will be based on the user's name pinyin retrieval data, Microsoft has provided a component installation package to handle non-English special language, called

Microsoft Visual Studio International Pack

Download this installation package, and then install the Simplified Chinese component

The default installation path is: C:\Program Files (x86) \microsoft Visual Studio International pack\simplified Chinese Pin-yin Conversion Library

To use this Kanji processing method in your project, you need to add the DLL files in that directory: ChnCharInfo.dll

Here are the methods available in this Simplified Chinese package

Test code:

usingMicrosoft.International.Converters.PinYinConverter;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceget Chinese Pinyin {classProgram {Static voidMain (string[] args) {            //1. Get pinyin for a specified Chinese characterChinesechar cc =NewChinesechar ('le'); //because Chinese characters are likely to be polyphone, looping through the output of all pinyin            foreach(varStrinchcc. Pinyins) {//the output is: Le4,yue4. (Note: Numbers on the back of Pinyin represent tones)Console.WriteLine (str); }            //2. Get this kanji character. Console.WriteLine (CC. Chinesecharacter);//output: Le//3. Gets the number of strokes for this character. Console.WriteLine (CC. Strokenumber);//Output results: 5//4. Get the number of pinyin for this character. Console.WriteLine (CC. Pinyincount);//Output results: 2//5. Compare the number of strokes for the given character and the instance character. The number of strokes in the output as "le" minus the number of strokes of Chinese characters to compareConsole.WriteLine (Cc.comparestrokenumber ('in'));//"le" word strokes more than the "medium" word number of strokes more than 1, output results: 1Console.WriteLine (Cc.comparestrokenumber ('Master'));//The number of strokes in the "Le" word is as many as the number of strokes in the "main" word, output: 0Console.WriteLine (Cc.comparestrokenumber ('Country'));//"Guo" the number of strokes than "le" word number of strokes more than 3, output: -3//6. Retrieves the number of characters with the specified stroke count. Console.WriteLine (Chinesechar.getcharcount (1)); //7. Retrieves all strings with the specified number of strokes.             Char[] Csamestrokenum = Chinesechar.getchars (1); foreach(varCinchcsamestrokenum)            {Console.WriteLine (c); }            //8. Gets all the phonetic characters for the given Ruby.             Char[] Csamepinyin = Chinesechar.getchars ("Shao4");//PS: Must specify phonetic tones of pinyin            foreach(varCinchCsamepinyin)            {Console.WriteLine (c); }            //9. There are many other waysConsole.readkey (); }    }}
View Code

Kanji Processing Components

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.