Home > Web Front-end > JS Tutorial > JavaScript Chinese to Pinyin implementation code has some bugs_javascript skills

JavaScript Chinese to Pinyin implementation code has some bugs_javascript skills

WBOY
Release: 2016-05-16 18:32:18
Original
1171 people have browsed it
1. Problem background:
When working on a project, I encountered a small business that displays the name of the customer department (Pinyin). There is a corresponding Pinyin under the department name, and in the existing database There is no corresponding field in , and the number of departments is relatively large. It is time-consuming to add. I wonder if it can be implemented in js and processed on the page.
2. Principle description
The program principle is very simple. You can find the data dictionary of Chinese pinyin on the Internet. However, since everyone knows that the Chinese characters in the GB2312 encoding are sorted by pinyin, as long as you know that each pinyin is first The Chinese character codes can be used to calculate the pinyin codes of all Chinese characters.
This article customizes the data dictionary used to store the corresponding Chinese character pinyin and ascii code, then converts the Chinese characters that need to be converted into ascii code (two digits), and finally searches the dictionary for matching. See the code for specific implementation.
3. Implementation code:
Copy code The code is as follows:



Call code:
Copy code The code is as follows:

/*Transfer To uppercase*/
Onblur = "alert(myConvertToUpper(this.value));"
/*Convert to lowercase*/
Onblur = "alert(myConvertToLower (this.value));"


[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template