Chinese pinyin seems to have been a difficult problem in the development of C #, no matter what the program has a certain bug, before the use of two scenarios.
1.chinese2spell.cs Some unrecognized kanji to Z
2.Microsoft Visual Studio International Feature Pack 1.0 even the "wide", "district" can not turn, very disappointing.
These are the 2010 before the program, at least there are heroes in the Chinese Pinyin constantly strive to find the most perfect is npinyin, in Googlecode can see its open source projects, http://code.google.com/p/npinyin/
Unrecognized words are very few, but also constantly maintain the update, increasingly perfect, recommend everyone to use.
Dll:http://files.cnblogs.com/files/guohu/npinyin-0.2.4588.20158-bin.zip
Source: Http://files.cnblogs.com/files/guohu/NPinyin-0.2.x-source_code.zip
Changes in v0.2.x
- 1, increase the support of different encoding format text, and increase the encoding conversion method pinyin.convertencoding
- 2. Reconstruct the acquisition of single-character pinyin, and return the character itself when no pinyin is found.
Wang Siyan July 23, 2012 Night
Convert Chinese to the. NET component of the phonetic text and initials. Example:
Using System;Using System.Collections.Generic;Using System.Text;Using Npinyin;Namespace Npinyintest{Class Program{Static void Main(String[]Args){String[]Maxims= New String[]{"Things often violate people, things are always human.","The steed is run out, the strong soldier is to fight out","To harness the rudder of destiny is to struggle." Do not have a glimmer of imagination, do not give up a little opportunity, do not stop working hard. ","If you fear the Rocky Mountains ahead, life will always be backwater.","Cowardly people will only be deterred, reckless people can only be cited as burning, only the truly courageous people can be invincible."};String[]Medicines= New String[] {"Povidone Iodine Solution","Open plug","Stove calamine Lotion", "Benzalkonium chloride paste","Ichthammol Ointment","Luoxing Ointment","Erythromycin Ointment","Hydrogenated Soft Cream","Qu Acetonide ointment","D-Hydroxy acid cream","Diclofenac ethylenediamine Cream","Frostbite Cream","Clindamycin Ointment","Special Terbinafine Ointment","Phthalocyanine Ftibamzone Ointment","Ketoconazole Ointment, suppository","Metronidazole suppository","Compound zedoary turmeric oil suppository"};Console.WriteLine("UTF8 sentence pinyin:");Foreach (StringSInchMaxims){Console.WriteLine("Kanji: {0}\n pinyin: {1}\n",S, Pinyin.Getpinyin(S));}Encodinggb2312= Encoding.GetEncoding("GB2312");Console.WriteLine("GB2312 Pinyin Simple code:");Foreach (StringMInchMedicines){StringS= Pinyin.Convertencoding(M, Encoding.UTF8,gb2312 console. Writeline ( "Pharmaceuticals: {0}\n Jane code: {1}\n" , s , pinyin. Getinitials (s, Gb2312 )); } Console. Readkey} } }
Run results
UTF8 sentence Pinyin: Chinese characters: Things often violate people, things always in human pinyin: Shi Chang Yu ren wei, shi Zong zai ren wei
Kanji: The steed is run out, the strong soldier is to play out the pinyin: June Ma Shi Pao chu lai de, Qiang Bing shi da chu lai de
Chinese characters: The rudder to harness destiny is struggle. Do not have a glimmer of imagination, do not give up a little opportunity, do not stop working hard. Pinyin: Jia Yu Ming yun de duo Shi Fen dou. Bu bao you yi si huan xiang, bu fa ng qi yi dian ji hui, bu ting zhi yi ri nu li.
Chinese characters: If fear of the Rocky Mountains ahead, life will always be backwater pinyin: Ru Guo Ju pa qian mian die Dang de Shan Yan, Sheng Ming Jiu Yong yuan zh i neng shi si shu I Yi Tan
Chinese characters: Cowardly people will only be deterred, reckless people can only be cited as the burning body, only the truly courageous people can invincible pinyin: nuo ruo de ren zhi hui Guo zu bu Qian, mang zhuang de ren zhi neng yin w ei sh Ao Shen, zhi you zhen Zheng Yong gan de ren cai neng suo xiang pi mi
GB2312 Pinyin Simple code: Medicine: Povidone Iodine Solution simple code: Jwtdry
Medicine: Open plug Jane Code: KSL
Medicine: Stove calamine Lotion Jane code: LGSXJ
Drug: Benzalkonium chloride, simple code: Bzlat
Medicine: Ichthammol Ointment Simple code: YSZRG
Medicine: Luoxing Ointment Simple code: MPLXRG
Medicine: erythromycin Ointment Simple code: HMSRG
Medicine: Hydrogenated Soft Paste simple code: QHKDSRG
Medicine: triamcinolone acetonide Ointment Simple code: QANDRG
Pharmaceuticals: Butyl-phenyl-hydroxy-acid Cream simple code: DBQSRG
Medicine: Diclofenac acid ethylenediamine Cream Simple code: Slfseyarg
Medicine: Frostbite Cream Simple code: DCG
Drugs: Clindamycin Ointment simple code: KMZRG
Medicine: Terbinafine Ointment Simple code: TBNFRG
Medicine: Ftibamzone Ointment Simple code: TDARG
Drugs: Ketoconazole Ointment, suppository simple code: MKZRG, SJ
Drug: metronidazole suppository simple code: JXZS
Medicine: Compound zedoary turmeric oil suppository simple code: Ffesys
C # kanji Pinyin (Npinyin) converts Chinese into pinyin full text or initials