package test;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Set;
public class Cn2Spell {
private static LinkedHashMap spellMap = null;
static {
if (spellMap == null) {
spellMap = new LinkedHashMap(400);
}
initialize();
}
private Cn2Spell() {
}
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);
spellPut("chuan", -19288);
spellPut("chuang", -19281);
spellPut("chui", -19275);
spellPut("chun", -19270);
spellPut("chuo", -19263);
spellPut("ci", -19261);
spellPut("cong", -19249);
spellPut("cou", -19243);
spellPut("cu", -19242);
spellPut("cuan", -19238);
spellPut("cui", -19235);
spellPut("cun", -19227);
spellPut("cuo", -19224);
spellPut("da", -19218);
spellPut("dai", -19212);
spellPut("dan", -19038);
spellPut("dang", -19023);
spellPut("dao", -19018);
spellPut("de", -19006);
spellPut("deng", -19003);
spellPut("di", -18996);
spellPut("dian", -18977);
spellPut("diao", -18961);
spellPut("die", -18952);
spellPut("ding", -18783);
spellPut("diu", -18774);
spellPut("dong", -18773);
spellPut("dou", -18763);
spellPut("du", -18756);
spellPut("duan", -18741);
spellPut("dui", -18735);
spellPut("dun", -18731);
spellPut("duo", -18722);
spellPut("e", -18710);
spellPut("en", -18697);
spellPut("er", -18696);
spellPut("fa", -18526);
spellPut("fan", -18518);
spellPut("fang", -18501);
spellPut("fei", -18490);
spellPut("fen", -18478);
spellPut("feng", -18463);
spellPut("fo", -18448);
spellPut("fou", -18447);
spellPut("fu", -18446);
spellPut("ga", -18239);
spellPut("gai", -18237);
spellPut("gan", -18231);
spellPut("gang", -18220);
spellPut("gao", -18211);
spellPut("ge", -18201);
spellPut("gei", -18184);
spellPut("gen", -18183);
spellPut("geng", -18181);
spellPut("gong", -18012);
spellPut("gou", -17997);
spellPut("gu", -17988);
spellPut("gua", -17970);
spellPut("guai", -17964);
spellPut("guan", -17961);
spellPut("guang", -17950);
spellPut("gui", -17947);
spellPut("gun", -17931);
spellPut("guo", -17928);
spellPut("ha", -17922);
spellPut("hai", -17759);
spellPut("han", -17752);
spellPut("hang", -17733);
spellPut("hao", -17730);
spellPut("he", -17721);
spellPut("hei", -17703);
spellPut("hen", -17701);
spellPut("heng", -17697);
spellPut("hong", -17692);
spellPut("hou", -17683);
spellPut("hu", -17676);
spellPut("hua", -17496);
spellPut("huai", -17487);
spellPut("huan", -17482);
spellPut("huang", -17468);
spellPut("hui", -17454);
spellPut("hun", -17433);
spellPut("huo", -17427);
spellPut("ji", -17417);
spellPut("jia", -17202);
spellPut("jian", -17185);
spellPut("jiang", -16983);
spellPut("jiao", -16970);
spellPut("jie", -16942);
spellPut("jin", -16915);
spellPut("jing", -16733);
spellPut("jiong", -16708);
spellPut("jiu", -16706);
spellPut("ju", -16689);
spellPut("juan", -16664);
spellPut("jue", -16657);
spellPut("jun", -16647);
spellPut("ka", -16474);
spellPut("kai", -16470);
spellPut("kan", -16465);
spellPut("kang", -16459);
spellPut("kao", -16452);
spellPut("ke", -16448);
spellPut("ken", -16433);
spellPut("keng", -16429);
spellPut("kong", -16427);
spellPut("kou", -16423);
spellPut("ku", -16419);
spellPut("kua", -16412);
spellPut("kuai", -16407);
spellPut("kuan", -16403);
spellPut("kuang", -16401);
spellPut("kui", -16393);
spellPut("kun", -16220);
spellPut("kuo", -16216);
spellPut("la", -16212);
spellPut("lai", -16205);
spellPut("lan", -16202);
spellPut("lang", -16187);
spellPut("lao", -16180);
spellPut("le", -16171);
spellPut("lei", -16169);
spellPut("leng", -16158);
spellPut("li", -16155);
spellPut("lia", -15959);
spellPut("lian", -15958);
spellPut("liang", -15944);
spellPut("liao", -15933);
spellPut("lie", -15920);
spellPut("lin", -15915);
spellPut("ling", -15903);
spellPut("liu", -15889);
spellPut("long", -15878);
spellPut("lou", -15707);
spellPut("lu", -15701);
spellPut("lv", -15681);
spellPut("luan", -15667);
spellPut("lue", -15661);
spellPut("lun", -15659);
spellPut("luo", -15652);
spellPut("ma", -15640);
spellPut("mai", -15631);
spellPut("man", -15625);
spellPut("mang", -15454);
spellPut("mao", -15448);
spellPut("me", -15436);
spellPut("mei", -15435);
spellPut("men", -15419);
spellPut("meng", -15416);
spellPut("mi", -15408);
spellPut("mian", -15394);
spellPut("miao", -15385);
spellPut("mie", -15377);
spellPut("min", -15375);
spellPut("ming", -15369);
spellPut("miu", -15363);
spellPut("mo", -15362);
spellPut("mou", -15183);
spellPut("mu", -15180);
spellPut("na", -15165);
spellPut("nai", -15158);
spellPut("nan", -15153);
spellPut("nang", -15150);
spellPut("nao", -15149);
spellPut("ne", -15144);
spellPut("nei", -15143);
spellPut("nen", -15141);
spellPut("neng", -15140);
spellPut("ni", -15139);
spellPut("nian", -15128);
spellPut("niang", -15121);
spellPut("niao", -15119);
spellPut("nie", -15117);
spellPut("nin", -15110);
spellPut("ning", -15109);
spellPut("niu", -14941);
spellPut("nong", -14937);
spellPut("nu", -14933);
spellPut("nv", -14930);
spellPut("nuan", -14929);
spellPut("nue", -14928);
spellPut("nuo", -14926);
spellPut("o", -14922);
spellPut("ou", -14921);
spellPut("pa", -14914);
spellPut("pai", -14908);
spellPut("pan", -14902);
spellPut("pang", -14894);
spellPut("pao", -14889);
spellPut("pei", -14882);
spellPut("pen", -14873);
spellPut("peng", -14871);
spellPut("pi", -14857);
spellPut("pian", -14678);
spellPut("piao", -14674);
spellPut("pie", -14670);
spellPut("pin", -14668);
spellPut("ping", -14663);
spellPut("po", -14654);
spellPut("pu", -14645);
spellPut("qi", -14630);
spellPut("qia", -14594);
spellPut("qian", -14429);
spellPut("qiang", -14407);
spellPut("qiao", -14399);
spellPut("qie", -14384);
spellPut("qin", -14379);
spellPut("qing", -14368);
spellPut("qiong", -14355);
spellPut("qiu", -14353);
spellPut("qu", -14345);
spellPut("quan", -14170);
spellPut("que", -14159);
spellPut("qun", -14151);
spellPut("ran", -14149);
spellPut("rang", -14145);
spellPut("rao", -14140);
spellPut("re", -14137);
spellPut("ren", -14135);
spellPut("reng", -14125);
spellPut("ri", -14123);
spellPut("rong", -14122);
spellPut("rou", -14112);
spellPut("ru", -14109);
spellPut("ruan", -14099);
spellPut("rui", -14097);
spellPut("run", -14094);
spellPut("ruo", -14092);
spellPut("sa", -14090);
spellPut("sai", -14087);
spellPut("san", -14083);
spellPut("sang", -13917);
spellPut("sao", -13914);
spellPut("se", -13910);
spellPut("sen", -13907);
spellPut("seng", -13906);
spellPut("sha", -13905);
spellPut("shai", -13896);
spellPut("shan", -13894);
spellPut("shang", -13878);
spellPut("shao", -13870);
spellPut("she", -13859);
spellPut("shen", -13847);
spellPut("sheng", -13831);
spellPut("shi", -13658);
spellPut("shou", -13611);
spellPut("shu", -13601);
spellPut("shua", -13406);
spellPut("shuai", -13404);
spellPut("shuan", -13400);
spellPut("shuang", -13398);
spellPut("shui", -13395);
spellPut("shun", -13391);
spellPut("shuo", -13387);
spellPut("si", -13383);
spellPut("song", -13367);
spellPut("sou", -13359);
spellPut("su", -13356);
spellPut("suan", -13343);
spellPut("sui", -13340);
spellPut("sun", -13329);
spellPut("suo", -13326);
spellPut("ta", -13318);
spellPut("tai", -13147);
spellPut("tan", -13138);
spellPut("tang", -13120);
spellPut("tao", -13107);
spellPut("te", -13096);
spellPut("teng", -13095);
spellPut("ti", -13091);
spellPut("tian", -13076);
spellPut("tiao", -13068);
spellPut("tie", -13063);
spellPut("ting", -13060);
spellPut("tong", -12888);
spellPut("tou", -12875);
spellPut("tu", -12871);
spellPut("tuan", -12860);
spellPut("tui", -12858);
spellPut("tun", -12852);
spellPut("tuo", -12849);
spellPut("wa", -12838);
spellPut("wai", -12831);
spellPut("wan", -12829);
spellPut("wang", -12812);
spellPut("wei", -12802);
spellPut("wen", -12607);
spellPut("weng", -12597);
spellPut("wo", -12594);
spellPut("wu", -12585);
spellPut("xi", -12556);
spellPut("xia", -12359);
spellPut("xian", -12346);
spellPut("xiang", -12320);
spellPut("xiao", -12300);
spellPut("xie", -12120);
spellPut("xin", -12099);
spellPut("xing", -12089);
spellPut("xiong", -12074);
spellPut("xiu", -12067);
spellPut("xu", -12058);
spellPut("xuan", -12039);
spellPut("xue", -11867);
spellPut("xun", -11861);
spellPut("ya", -11847);
spellPut("yan", -11831);
spellPut("yang", -11798);
spellPut("yao", -11781);
spellPut("ye", -11604);
spellPut("yi", -11589);
spellPut("yin", -11536);
spellPut("ying", -11358);
spellPut("yo", -11340);
spellPut("yong", -11339);
spellPut("you", -11324);
spellPut("yu", -11303);
spellPut("yuan", -11097);
spellPut("yue", -11077);
spellPut("yun", -11067);
spellPut("za", -11055);
spellPut("zai", -11052);
spellPut("zan", -11045);
spellPut("zang", -11041);
spellPut("zao", -11038);
spellPut("ze", -11024);
spellPut("zei", -11020);
spellPut("zen", -11019);
spellPut("zeng", -11018);
spellPut("zha", -11014);
spellPut("zhai", -10838);
spellPut("zhan", -10832);
spellPut("zhang", -10815);
spellPut("zhao", -10800);
spellPut("zhe", -10790);
spellPut("zhen", -10780);
spellPut("zheng", -10764);
spellPut("zhi", -10587);
spellPut("zhong", -10544);
spellPut("zhou", -10533);
spellPut("zhu", -10519);
spellPut("zhua", -10331);
spellPut("zhuai", -10329);
spellPut("zhuan", -10328);
spellPut("zhuang", -10322);
spellPut("zhui", -10315);
spellPut("zhun", -10309);
spellPut("zhuo", -10307);
spellPut("zi", -10296);
spellPut("zong", -10281);
spellPut("zou", -10274);
spellPut("zu", -10270);
spellPut("zuan", -10262);
spellPut("zui", -10260);
spellPut("zun", -10256);
spellPut("zuo", -10254);
spellPut("", -10247);
}
/**
* 获得单个字符的ASCII
*
* @param cn
* 输入字符
* @return 错误返回0,否则返回ASCII
*/
public static int getCnAscii(char cn) {
byte[] bytes = (String.valueOf(cn)).getBytes();
// 错误
if (bytes == null || bytes.length > 2 || bytes.length <= 0) {
return 0;
}
// 英文字符
if (bytes.length == 1) {
return bytes[0];
}
// 中文字符
if (bytes.length == 2) {
int highByte = 256 + bytes[0];
int lowByte = 256 + bytes[1];
int ascii = (256 * highByte + lowByte) - 256 * 256;
// System.out.println("ASCII=" + ascii);
return ascii;
}
// 错误
return 0;
}
/**
* 根据ASCII码到SpellMap中查找对应的拼音
*
* @param int
* 字符对应的ASCII
* @return 拼音,首先判断ASCII是否>0&<160,如果是返回对应的字符,
* 否则到SpellMap中查找,如果没有找到拼音,则返回null,如果找到则返回拼音.
*/
public static String getSpellByAscii(int ascii) {
// 单字符
if (ascii > 0 && ascii < 160) {
return String.valueOf((char) ascii);
}
// 不知道的字符
if (ascii < -20319 || ascii > -10247) {
return null;
}
Set keySet = spellMap.keySet();
Iterator it = keySet.iterator();
String spell0 = null;
;
String spell = null;
int asciiRang0 = -20319;
int asciiRang;
while (it.hasNext()) {
spell = (String) it.next();
Object valObj = spellMap.get(spell);
if (valObj instanceof Integer) {
asciiRang = ((Integer) valObj).intValue();
// 区间找到
if (ascii >= asciiRang0 && ascii < asciiRang) {
return (spell0 == null) ? spell : spell0;
} else {
spell0 = spell;
asciiRang0 = asciiRang;
}
}
}
return null;
}
/**
* 返回字符串的全拼,是汉字转化为全拼,其它字符不进行转换
*
* @param String
* 字符串
* @return 转换成全拼后的字符串
*/
public static String getFullSpell(String cnStr) {
if (null == cnStr || "".equals(cnStr.trim())) {
return cnStr;
}
char[] chars = cnStr.toCharArray();
StringBuffer retuBuf = new StringBuffer();
for (int i = 0, Len = chars.length; i < Len; i++) {
int ascii = getCnAscii(chars[i]);
if (ascii == 0) {
retuBuf.append(chars[i]);
} else {
String spell = getSpellByAscii(ascii);
if (spell == null) {
retuBuf.append(chars[i]);
} else {
retuBuf.append(spell);
}
}
}
return retuBuf.toString();
}
public static void main(String[] args) {
String str = null;
str = "谢海101普降喜雨";
System.out.println("Spell=" + Cn2Spell.getFullSpell(str));
str = "张牙舞爪》。,";
System.out.println("Spell=" + Cn2Spell.getFullSpell(str));
str = "李鹏,可耻下场。";
System.out.println("Spell=" + Cn2Spell.getFullSpell(str));
str = "猪油,猪八戒。做";
System.out.println("Spell=" + Cn2Spell.getFullSpell(str));
}
}
相关推荐
Cn2Spell.java
可直接依赖 compile 'com.belerweb:pinyin4j:2.5.0' 转载网址:https://blog.csdn.net/wanxuedong/article/details/64213295
Cn2Spell类 汉字转换成汉语拼音,英文字符不变
package com.cmcc.util;import net.sourceforge.pinyin4j.PinyinHelper;import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;import ne...
STM32L151C8T6低功耗实战:RTC闹钟唤醒停机模式的配置与优化
本文详细介绍了如何在STM32L151C8T6微控制器上配置与优化RTC闹钟唤醒停机模式,以实现极致的低功耗设计。文章从核心原理出发,结合STM32CubeMX配置实战,深入讲解了进入停机模式前的关键准备工作、唤醒后的系统恢复流程,并分享了将功耗降至个位数微安级的深度优化技巧与常见问题解决方案。
JAVA汉子和拼音的转化
public class Cn2Spell { /** * 汉字转换位汉语拼音首字母,英文字符不变 * * @param chines 汉字 * @return 拼音 */ public static String converterToFirstSpell(String chines) { String pinyinName = ""; char[] nam
STM32与AD7606的SPI通信优化:提升高精度数据采集效率
本文深入探讨了STM32与AD7606的SPI通信优化策略,旨在提升高精度数据采集系统的效率与稳定性。文章从硬件连接、电源去耦、PCB布局等基础环节入手,详细解析了软件驱动中SPI模式配置、DMA应用及精准时序控制等关键优化技术,并提出了系统级的性能提升方案,帮助开发者解决高速采样下的数据跳动、效率瓶颈等实际问题。
AutoSAR开发实战:如何用Matlab/Simulink从零搭建SWC组件(附完整代码示例)
本文详细介绍了使用Matlab/Simulink从零开发AutoSAR SWC组件的全流程,包括环境配置、ARXML文件导入、算法模型开发、代码生成与集成验证等关键步骤。通过实战案例和完整代码示例,帮助开发者掌握AutoSAR标准下的软件开发技术,提升汽车电子系统的开发效率。
Android中汉字转拼音的两种方法,优劣比较
一、前言 在我们的开发中,有时会有这样的需求,就是联系人列表按照拼音顺序排列(如通讯录)。于是,我也在网上搜到了许多这类的文章,就两种最常见的做法在此进行简单的比较和分析 二、汉字转拼音的方法 使用第三方pinyin4j的jar包。 下载地址 , Android Studio也可直接依赖 compile 'com.belerweb:pinyin
HarmonyOS NEXT 开发者预览版Beta招募应知测试
本次HarmonyOS NEXT 开发者预览版 Beta 招募活动为开发者预览版尝鲜升级,主要供开发者进行应用调测使用,除部分系统应用外,其他所有应用将被清除,因此在进行HarmonyOS NEXT 开发者预览版升级前,需进行数据备份。通过应知测试,并提交了参加HarmonyOS NEXT 开发者预览版招募 Beta 活动的报名信息,就会立刻审核通过并且收到新版本。手机在参加HarmonyOS NEXT 开发者预览版 Beta 招募活动前,需要对应机型升级到招募要求对应的基线版本,并预留内存空间。
Java汉字转换为拼音
[code="java"] /** * Java 汉字转换为拼音 * * @author 我自是年少,韶华倾负。 * @since 0.1_2012-12-27 */ public class CharacterParser { private static int[] pyvalue = new int[] {-20319, -20317, -20304, -202...
用scons编译STM32F103工程
想用vscode来实现代码的编辑与调试代码,原先这个工程是用STM32CUBEIDE建立的,参照STM32CUBEIDE的编译过程,编写了下面的scons脚本,scons是初次了解,既然是python脚本,那么会什么就怎么写吧。 import os import sys import glob cross_compiler_prefix = 'arm-none-eabi-' CC = cross_compiler_prefix+'gcc' CXX = cross_compiler_prefix+'g+
【CASS精品教程】013:CASS9.1生成标准图幅案例教程
在CASS中,可以很方便的生成标准图幅,如50*50。本文演示cass中,根据测区范围标准图幅生成过程。
java 拼音转汉字_用Java转化汉字为拼音全拼
/*** @(#)CnToSpell.java* 版权声明 Easydozer版权所有 违者必究** 修订记录:* 1)更改者:Easydozer* 时 间:2004-10-20* 描 述:创建*/package com.easydozer.commons.util;import java.util.Iterator;import java.util.LinkedHashMap;impo...
华为OD新系统机试真题 - API请求日志去重分析
华为OD新系统机试真题【API请求日志去重分析】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD4月15号机试真题【API请求日志去重分析】
java 获取拼音码_Java获取汉字拼音的全拼和首拼实现代码分享
import java.util.Collections;import java.util.Iterator;import java.util.LinkedHashMap;import java.util.Map;/*** 将汉字转化为全拼*/public class CnToSpell1 {private static Map spellMap = null;//存放生僻字和其拼音的Mappri...
YOLOv12涨点改进 | 全网独家首发Conv改进篇 | Arxiv 2025 | 引入一种新的WConv加权卷积改进YOLOv12,显著提升其特征提取能力和目标检测精度
本文提出了一种新型加权卷积(WConv)模块,通过引入最优密度函数动态调整邻域像素权重,显著提升了YOLOv12目标检测性能。WConv在保持参数数量不变的情况下,提高了模型精度(VGG准确率提升10%)、增强了小目标检测能力,并改善了多尺度特征提取。文中详细介绍了模块原理、网络结构改进方法,并提供了核心代码实现和yaml配置文件。实验表明,该方法在图像任务中最高可降低53%的损失,虽然会带来11%的时间开销,但具有优异的鲁棒性。该技术可广泛应用于2D/3D图像处理领域。
jdk-8u144-linux-x64.tar.gz.
该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包
java获取拼音_java获取中文拼音
/**使用方法Stringstr=null;try{str=newString("猪八戒".getBytes(),"GBK");}catch(UnsupportedEncodingExceptionex){}System.out.println("Spell="+CnToSpell.getFullSpell(str));*/importjava.util.Iterator...
Statistics and Machine Learning Toolbox
Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具
Java实现汉字转换为拼音
引用自http://blog.csdn.net/zzpchina/archive/2005/07/19/428487.aspx,感谢zzpchinaimport java.util.Iterator;import java.util.LinkedHashMap;import java.util.Set;/** * 汉字转化为全拼 * JDK版本: 1.4public class CnToSpell
计算机控制技术及应用
《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。
jre9下载 jdk9
(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】
java 实现汉字转换拼音_Java实现汉字转换为拼音
#re: Java实现汉字转换为拼音2006-11-24 15:06芦苇JAVA将汉字转化成拼音的方法/** *//**############################################################################## DESCRIBE 将汉字转化成拼音# DATE 2006-7-12# COMPANY FLX# PORJECT JAVA...
java 汉字转拼音_Java实现汉字转换为拼音(转)
import java.util.Iterator;import java.util.LinkedHashMap;import java.util.Set;/***汉字转化为全拼*JDK版本:1.4public class CnToSpell {private static LinkedHashMap spellMap = null;static {if (spellMap == null) {s...
java全拼,Java获取汉字全拼和首拼
import java.util.Collections;import java.util.Iterator;import java.util.LinkedHashMap;import java.util.Map;/*** 将汉字转化为全拼*/public class CnToSpell {private static Map spellMap = null;// 存放生僻字和其拼音的Mappri...
java ascii转换成汉字_Java实现将中文转成拼音和ASCII码
packageminyuantec.backupsystem.action;importnet.sourceforge.pinyin4j.PinyinHelper;importnet.sourceforge.pinyin4j.format.HanyuPinyinCaseType;importnet.sourceforge.pinyin4j.format.HanyuPinyinOutputForma...
java实现中文汉字转中文全拼和拼音首字母缩写的方法
用户为新建产品命名时通常使用中文,而假如后台需要根据用户输入的中文名称进行字段拼接时,就需要将中文汉字转化为中文。所以就用到了pinyin4j这个java工具包(官方网站:http://pinyin4j.sourceforge.net/)。这个工具包是开源的,对于一般常用汉字,转化正确率还是不错的。 对于使用maven的项目,直接添加依赖 <dependency> <groupI...
汉字、拼音、ASCII码的转换
package com; import java.util.Iterator;import java.util.LinkedHashMap;import java.util.Set; public class Chang { private static LinkedHashMap spellMap = null; static { if (spellMap ==
Java 实现中文汉字转拼音
汉字转拼音
java中文转化成拼音
import java.io.UnsupportedEncodingException; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Set; public class CntoSpell { private static LinkedHashMap spellMap =
java 找出句子中拼音代表的汉子_java根据汉字获取对应的拼音
/*** 得到中文全拼* @param src 需要转化的中文字符串* @return*/public static String getPingYin(String src){char[] t1 = null;t1 = src.toCharArray();String[] t2 = new String[t1.length];HanyuPinyinOutputFormat t3 = new Ha...
567




被折叠的 条评论
为什么被折叠?



