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)