Use Microsoft Language Pack to convert Chinese characters to PinYin

Source: Internet
Author: User

There are many Chinese character-to-PinYin conversion solutions on the Internet, but they do not know the performance and reliability. Therefore, based on the authoritative choice principle, I still want to find an official solution. The following is a practical Language Pack for Microsoft to convert Chinese characters to pinyin.

 

The installation package contains multiple languages, such as Japanese, Chinese, and Korean. Select to install CHSPinYinConv. msi. After that, you can reference ChnCharInfo. dll in the installation directory in the project.

 

The following is a demo of converting Chinese characters into pinyin.

 

 

Using Microsoft. international. converters. pinYinConverter; using System. collections. generic; using System. linq; using System. text; namespace Suspects. dll. util {publicclassPinYinUtil {// returns the publicstaticstring getSimplePinYin (stringinputTxt) {string shortR =; foreach (char cin inputTxt. trim () {ChineseChar chineseChar = newChineseChar (c); shortR + = chineseChar. pinyins [0]. substring (0, 1 ). toLower () ;}return shortR;} // returns the full publicstaticstring getAllPinYin (string inputTxt) {string allR =; foreach (char cin inputTxt. trim () {ChineseChar chineseChar = newChineseChar (c); allR + = chineseChar. pinyins [0]. substring (0, chineseChar. pinyins [0]. length-1 ). toLower () ;}return allR ;}}}


 

 

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.