RSS
热门关键字:  java  Ajax  JSP  JSF  Struts
当前位置 : 首页>Java>列表

JAVA实现把汉字转化成拼音

来源: 作者: 时间:2008-03-03 点击:

            }
            String text = from.getText();
            to.setText(CnToSpell.getFullSpell(text));
            c.pack();
        }
    }

    public static void main(String []  args) {
        CnToSpell2GUI g = new CnToSpell2GUI();
    }
}



------------------------------------------------------------------------
/**
 * @(#)CnToSpell.java 
 * 版权声明 Easydozer 版权所有 违者必究 
 *
 * 修订记录:
 * 1)更改者:Easydozer
 *   时 间:2004-10-20 
 *   描 述:创建
 */
package com.easydozer.commons.util;

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

/**
 * 
汉字转化为全拼

 * 
JDK版本:
1.4

 * @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);

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册