Place database in Region table region Chinese name--English (more than 3,000 data)

Source: Internet
Author: User
Tags bulk insert

I now have more than 3,000 data in the Database Area table, now the demand is to convert each line of records in the name of the region into English (that is Hanyu Pinyin), while saving up, a little more intuitive

I would like to ask, there is no Chinese language library, I write a PHP program, the Chinese into pinyin, and then through the SQL statement Bulk INSERT, can not be a line to change it.
What can we do? Please answer

Reply content:

I now have more than 3,000 data in the Database Area table, now the demand is to convert each line of records in the name of the region into English (that is Hanyu Pinyin), while saving up, a little more intuitive

I would like to ask, there is no Chinese language library, I write a PHP program, the Chinese into pinyin, and then through the SQL statement Bulk INSERT, can not be a line to change it.
What can we do? Please answer

1, the project needs to put in Pinyin4j-2.5.0.jar, can be downloaded online, here does not provide download address 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;/** * Kanji Conversion bit Hanyu Pinyin, English characters unchanged * */Public Class Cn2spell {/** * Kanji conversion bit initials, English characters unchanged * @param chines kanji * @return Pinyin */Public St           Atic 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 pinyin, English characters unchanged * @param chines kanji * @return Pinyin */public static String Conver           Tertospell (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] > +) {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 Java World"));      System.out.println (Convertertospell ("Welcome to 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.