The accident scene of the net character to Pinyin

Source: Internet
Author: User

ASP-Pinyin to Chinese

Requirements background:

Yesterday encountered a problem, is the face of centralized system to set a large number of users to set the default user name, password, permissions (role), while requiring the user name is the full spelling of the name, looking back to the next guy, his arm-in-the-sleeve ready to set a manual, my eyes are not consciously pumped, Because this need to set up the customer account is only bedrooms people, that manual entry finished hand also have cramps, not to mention there are 800 supposedly users to input, do not want to understand why no one has asked this demand. As a daily spirit of every line of code are running to change the world of programmers, this is a good chance to miss, the cool to tell the next friend, "This live I come ...", and then there are the following series of questions. Go back before also very Shing and home that adult said, help buddies put computer table out, I tonight is to work overtime person [put over].

Implementation process:

Because have not done this aspect of function before, back home on the computer to find a bit of information (as if serious find can find, so superstitious), information about:

Poor lifting Hanyu Pinyin and Chinese character coding, traverse comparison to find the corresponding pinyin, I myself also find a few kinds of copy down to try, test results are very positive, very three, very easy to confuse me, the peace of mind to sleep, the next day, from the results submitted there is a day, the next day the code directly to the project began to write, finished testing a Results when a large number of people name entered, before the poor lifting pinyin and Chinese character coding bug exposed, more than 100 people about more than 10 people's name can not be identified, for example, Hongyu, Yue, Nan, Ting (Hongyu did not come out I actually do not blame it, originally I do not know), the middle of these words, looked at the breakpoint, obviously found the code Just can't get out. Alas, I have what method, I also very helpless. Just beginning to think that the word is really uncommon, in the initial judgment of the program corresponding to the pinyin (count not cheating), the results with the analysis of the exposed to more and more Chinese characters, decisively give up this method, there is a poor lifting pinyin corresponding Chinese characters, I think it is poor lifting, a large, and garbled like, I also from the blog below to see the author said, look not to use, in fact, very useful, I believe your evil ~!

How can I be so wordy, on the right dish:

  1. Vsintlpack1.zip
  2. After downloading Vsintlpack1.zip, unzip the installation of Chspinyinconv.msi, such as install 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.

  4. Test code: Class file
    usingMicrosoft.International.Converters.PinYinConverter;namespaceXlzf. box{ Public classPinyinhelper {//returns a simple spelling of a string         Public stringGetsimplepinyin (stringinputtxt) {            stringSHORTR =""; foreach(CharCininchInputtxt.trim ()) {Chinesechar Chinesechar=NewChinesechar (CIN); SHORTR+ = chinesechar.pinyins[0]. Substring (0,1).            ToLower (); }            returnShortr; }        //return string full spell         Public stringGetallpinyin (stringinputtxt) {            stringAllr =""; foreach(CharCininchInputtxt.trim ()) {Chinesechar Chinesechar=NewChinesechar (CIN); Allr+ = chinesechar.pinyins[0]. Substring (0, chinesechar.pinyins[0]. Length-1).            ToLower (); }            returnAllr; }    }}
  5. Page background:
    protected void Btn_zhuan_click (object  sender, EventArgs e) {      new  pinyinhelper ();       string Hanzi = Tb_hanzi. Text.trim ();       = Chinapy.getallpinyin (hanzi);       = Chinapy.getsimplepinyin (Hanzi);}
  6. Page Front Desk:
    <Divclass= "Row"style= "margin-top:20px;">     <Divclass= "Col-md-12">                <Divclass= "Col-md-2">                    <Divclass= "Input-group">                        <spanclass= "Input-group-addon">Chinese characters</span>                        <Asp:textboxrunat= "Server"ID= "Tb_hanzi"CssClass= "Form-control"></Asp:textbox>                    </Div>                </Div>                <Divclass= "Col-md-2">                    <Divclass= "Input-group">                        <spanclass= "Input-group-addon">Full spell</span>                        <Asp:textboxrunat= "Server"ID= "Tb_pingyin"CssClass= "Form-control"></Asp:textbox>                    </Div>                </Div>                <Divclass= "Col-md-2">                    <Divclass= "Input-group">                        <spanclass= "Input-group-addon">First letter</span>                        <Asp:textboxrunat= "Server"ID= "Tb_shouzimu"CssClass= "Form-control"></Asp:textbox>                    </Div>                </Div>                <Divclass= "Col-md-2">                    <Asp:buttonrunat= "Server"ID= "Btn_zhuan"CssClass= "Btn btn-primary"Text= "Convert"OnClick= "Btn_zhuan_click" />                </Div>         </Div>    </Div>
  7. Results:
  8. This is a Microsoft boss out of a DLL, but similar to some of the polyphone just met, especially the surname, translation is wrong, really very embarrassing. Make sure there's nothing wrong with this piece of pinyin. Plus a few questions, grinding chirp since 12 o'clock night, riding a small electric donkey braved the cold autumn wind and thick fog home.
  9. The above section turns from: Werewolf 666

  

  

  

The accident scene of the net character to Pinyin

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.