C # chinese generation Pinyin (Microsoft Official program)

Source: Internet
Author: User

The login name of the user in the project development is the pinyin that the Administrator automatically generates after entering Chinese characters in the background. For example, enter: Zhang San, the login automatically generates Zhangsan.

I've looked at a lot of ways online:

such as: http://blog.csdn.net/nengzhong/article/details/4210039 and other methods, but during the conversion process, some Chinese it is not recognized.

So, run around, finally found the best solution for Microsoft's official:

Microsoft provides a Microsoft Visual Studio International Pack Class Library package, Vsintlpack1.zip

There is a class library: Simplified Chinese pin-yin Conversion Library supports common properties for Simplified Chinese characters

Specific operation:

1, Vsintlpack1.zip for:

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


2, download Vsintlpack1.zip , unzip the installation of Chspinyinconv.msi, such as installation to C:\Program Files\Microsoft Visual Studio International Pack\simplified Chinese Pin-yin Conversion Library, you can see the following files.

3. Add references in the project, and add Reference ChnCharInfo.dll under the Step 2 installation directory.

After the reference succeeds

4. The test method is as follows :

Private stringConverttopinyin (stringstr) {            stringPystr =""; foreach(CharIteminchStr. ToCharArray ()) {if(Microsoft.International.Converters.PinYinConverter.ChineseChar.IsValidChar (item)) { Microsoft.International.Converters.PinYinConverter.ChineseChar cc=NewMicrosoft.International.Converters.PinYinConverter.ChineseChar (item); //Pystr + = string. Join ("", CC. Pinyins.toarray ());Pystr + = cc. pinyins[0]. Substring (0Cc. pinyins[0]. Length-1); //Pystr + = cc. Pinyins[0]. Substring (0, CC.) Pinyins[0]. LENGTH-1). Substring (0, 1). ToLower ();                }                Else{pystr+=item.                ToString (); }            }            returnPystr; }

C # Chinese generation Pinyin (Microsoft Official program)

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.