WEB开发网
开发学院WEB开发Jsp 用Java转化汉字为拼音全拼 阅读

用Java转化汉字为拼音全拼

 2008-01-05 09:38:25 来源:WEB开发网   
核心提示:package com.easydozer.commons.util;import java.util.Iterator;import java.util.LinkedHashMap;import java.util.Set;/** * <PRe>汉字转化为全拼</pre> * <BR&g

  package com.easydozer.commons.util;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Set;

/**
* <PRe>汉字转化为全拼</pre>
* <BR><DL><DT><B>JDK版本:</B></DT><BR><DD>1.4</DD></DL>
* @author 谢计生
* @version 1.0
* @see
* @since 1.0
*/
public class CnToSpell
{
private static LinkedHashMap spellMap = null;

static
{
if(spellMap == null){
spellMap = new LinkedHashMap(400);
}
initialize();
System.out.println("Chinese transfer Spell Done.");
}

private CnToSpell()
{
}

private static void spellPut(String spell,int ascii)
{
spellMap.put(spell,new Integer(ascii));
}

private static void initialize()
{
spellPut("a", -20319);
spellPut("ai", -20317);
spellPut("an", -20304);
spellPut("ang", -20295);
spellPut("ao", -20292);
spellPut("ba", -20283);
spellPut("bai", -20265);
spellPut("ban", -20257);
spellPut("bang", -20242);
spellPut("bao", -20230);
spellPut("bei", -20051);
spellPut("ben", -20036);
spellPut("beng", -20032);
spellPut("bi", -20026);
spellPut("bian", -20002);
spellPut("biao", -19990);
spellPut("bie", -19986);
spellPut("bin", -19982);
spellPut("bing", -19976);
spellPut("bo", -19805);
spellPut("bu", -19784);
spellPut("ca", -19775);
spellPut("cai", -19774);
spellPut("can", -19763);
spellPut("cang", -19756);
spellPut("cao", -19751);
spellPut("ce", -19746);
spellPut("ceng", -19741);
spellPut("cha", -19739);
spellPut("chai", -19728);
spellPut("chan", -19725);
spellPut("chang", -19715);
spellPut("chao", -19540);
spellPut("che", -19531);
spellPut("chen", -19525);
spellPut("cheng", -19515);
spellPut("chi", -19500);
spellPut("chong", -19484);
spellPut("chou", -19479);
spellPut("chu", -19467);
spellPut("chuai", -19289);

Tags:Java 转化 汉字

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接