Name of the region table area in the database in Chinese> English (more than 3 thousand pieces of data)

Source: Internet
Author: User
I now have more than pieces of data in the database region table. now I want to convert the region names in each row of records into English (that is, Chinese pinyin) and save them at the same time, I would like to ask if there is a Chinese language library. I write a PHP program myself to convert Chinese into a spelling...

I now have more than pieces of data in the database region table. now I want to convert the region names in each row of records into English (that is, Chinese pinyin) and save them at the same time, more intuitive

I would like to ask if there is a Chinese language library. I write a PHP program myself to convert Chinese into pinyin, and then insert them in batches using SQL statements. I cannot change it in one row.
What can we do ?? Please answer

Reply content:

I now have more than pieces of data in the database region table. now I want to convert the region names in each row of records into English (that is, Chinese pinyin) and save them at the same time, more intuitive

I would like to ask if there is a Chinese language library. I write a PHP program myself to convert Chinese into pinyin, and then insert them in batches using SQL statements. I cannot change it in one row.
What can we do ?? Please answer

1, under the project need to put into the pinyin4j-2.5.0.jar, can download again online, here does not provide 2, code: import net. sourceforge. pinyin4j. pinyinHelper; import net. sourceforge. pinyin4j. format. hanyuPinyinCaseType; import net. sourceforge. pinyin4j. format. hanyuPinyinOutputFormat; import net. sourceforge. pinyin4j. format. hanyuPinyinToneType; import net. sourceforge. pinyin4j. format. exception. badHanyuPinyinOutputFormatCombination;/*** Chinese character conversion bit: Chinese pinyin, English character unchanged **/public class Cn2Spell {/*** Chinese character conversion bit: Chinese pinyin first letter, english characters remain unchanged * @ param chines Chinese characters * @ return pinyin */public static String converterToFirstSpell (String chines) {String pinyinName = ""; char [] nameChar = chines. toCharArray (); HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat (); defaultFormat. setCaseType (HanyuPinyinCaseType. LOWERCASE); defaultFormat. setToneType (HanyuPinyinToneType. WITHOUT_TONE); for (int I = 0; I <nameChar. length; I ++) {if (nameChar [I]> 128) {try {pinyinName + = PinyinHelper. toHanyuPinyinStringArray (nameChar [I], defaultFormat) [0]. charAt (0);} catch (BadHanyuPinyinOutputFormatCombination e) {e. printStackTrace () ;}} else {pinyinName + = nameChar [I] ;}return pinyinName ;}/ *** Chinese character conversion bits in Chinese pinyin, english characters remain unchanged * @ param chines Chinese characters * @ return pinyin */public static String converterToSpell (String chines) {String pinyinName = ""; char [] nameChar = chines. toCharArray (); HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat (); defaultFormat. setCaseType (HanyuPinyinCaseType. LOWERCASE); defaultFormat. setToneType (HanyuPinyinToneType. WITHOUT_TONE); for (int I = 0; I <nameChar. length; I ++) {if (nameChar [I]> 128) {try {pinyinName + = PinyinHelper. toHanyuPinyinStringArray (nameChar [I], defaultFormat) [0];} catch (BadHanyuPinyinOutputFormatCombination e) {e. printStackTrace () ;}} else {pinyinName + = nameChar [I] ;}return pinyinName;} public static void main (String [] args) {System. out. println (converterToFirstSpell ("Welcome to the Java World"); System. out. println (converterToSpell ("Welcome to the Java World "));}}

Https://github.com/overtrue/p...

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.