import java.util.collections; import java.util.iterator; import java.util.linkedhashmap; import java.util.map; / ** * 将汉字转化为全拼 */ public class cNtospell1 {private static map <string, integer> spellmap = null; // 存放生僻字和其拼音的 Mapa mapa estático privado <caracteres, string> uncomcomonwordsmap = null; static {if (spellmap == null) {spellmap = collections.synchronizedmap (new Linkedhashmap <String, Integer> (396)); no compomiswordsmap = collections.synchronizedMap (nuevo Linkedhashmap <caracteres, cadena> (200)); } Initialize (); ANEDUNCOMMONWORDS (); } private cntospell1 () {} / ** * 初始化 * / private static void inicialize () {spellmap.put ("'a", -20319); spellmap.put ("'ai", -20317); spellmap.put ("'an", -20304); SpellMap.put ("'Ang", -20295); SpellMap.put ("'Ao", -20292); SpellMap.put ("BA", -20283); SpellMap.put ("Bai", -20265); SpellMap.put ("Ban", -20257); spellmap.put ("bang", -20242); spellmap.put ("bao", -20230); spellmap.put ("bei", -20051); spellmap.put ("ben", -20036); spellmap.put ("beng", -20032); SpellMap.put ("BI", -20026); SpellMap.put ("Bian", -20002); SpellMap.put ("Biao", -19990); spellmap.put ("bie", -19986); spellmap.put ("bin", -19982); spellmap.put ("bing", -19976); spellmap.put ("bo", -19805); spellmap.put ("bu", -19784); SpellMap.put ("CA", -19775); SpellMap.put ("Cai", -19774); SpellMap.put ("Can", -19763); SpellMap.put ("CANG", -19756); SpellMap.put ("Cao", -19751); SpellMap.put ("CE", -19746); spellmap.put ("ceng", -19741); SpellMap.put ("cha", -19739); SpellMap.put ("Chai", -19728); SpellMap.put ("Chan", -19725); SpellMap.put ("Chang", -19715); SpellMap.put ("Chao", -19540); SpellMap.put ("Che", -19531); SpellMap.put ("Chen", -19525); SpellMap.put ("Cheng", -19515); spellmap.put ("chi", -19500); SpellMap.put ("Chong", -19484); SpellMap.put ("Chou", -19479); spellmap.put ("chu", -19467); SpellMap.put ("Chuai", -19289); SpellMap.put ("Chuan", -19288); SpellMap.put ("chuang", -19281); SpellMap.put ("chui", -19275); spellmap.put ("chun", -19270); spellmap.put ("chuo", -19263); SpellMap.put ("CI", -19261); SpellMap.put ("Cong", -19249); spellmap.put ("cou", -19243); SpellMap.put ("Cu", -19242); SpellMap.put ("Cuan", -19238); SpellMap.put ("Cui", -19235); SpellMap.put ("CUN", -19227); SpellMap.put ("Cuo", -19224); spellmap.put ("da", -19218); SpellMap.put ("Dai", -19212); SpellMap.put ("Dan", -19038); SpellMap.put ("Dang", -19023); SpellMap.put ("Dao", -19018); SpellMap.put ("DE", -19006); SpellMap.put ("Deng", -19003); SpellMap.put ("DI", -18996); SpellMap.put ("Dian", -18977); SpellMap.put ("Diao", -18961); spellmap.put ("morir", -18952); SpellMap.put ("ding", -18783); SpellMap.put ("DIU", -18774); spellmap.put ("dong", -18773); spellmap.put ("dou", -18763); spellmap.put ("du", -18756); SpellMap.put ("duan", -18741); SpellMap.put ("DUI", -18735); spellmap.put ("dun", -18731); spellmap.put ("duo", -18722); SpellMap.put ("'E", -18710); SpellMap.put ("'En", -18697); SpellMap.put ("'er", -18696); spellmap.put ("fa", -18526); SpellMap.put ("Fan", -18518); SpellMap.put ("Fang", -18501); SpellMap.put ("Fei", -18490); SpellMap.put ("Fen", -18478); SpellMap.put ("Feng", -18463); SpellMap.put ("fo", -18448); SpellMap.put ("fou", -18447); spellmap.put ("fu", -18446); spellmap.put ("ga", -18239); spellmap.put ("gai", -18237); spellmap.put ("gan", -18231); Spellmap.put ("pandilla", -18220); spellmap.put ("gao", -18211); spellmap.put ("GE", -18201); SpellMap.put ("GEI", -18184); spellmap.put ("gen", -18183); SpellMap.put ("Geng", -18181); spellmap.put ("gong", -18012); SpellMap.put ("Gou", -17997); SpellMap.put ("GU", -17988); SpellMap.put ("Gua", -17970); SpellMap.put ("Guai", -17964); SpellMap.put ("Guan", -17961); SpellMap.put ("Guang", -17950); SpellMap.put ("GUI", -17947); SpellMap.put ("Gun", -17931); SpellMap.put ("Guo", -17928); spellmap.put ("ha", -17922); SpellMap.put ("Hai", -17759); SpellMap.put ("Han", -17752); SpellMap.put ("Hang", -17733); spellmap.put ("hao", -17730); SpellMap.put ("He", -17721); SpellMap.put ("HEI", -17703); SpellMap.put ("Hen", -17701); SpellMap.put ("Heng", -17697); SpellMap.put ("Hong", -17692); SpellMap.put ("Hou", -17683); SpellMap.put ("Hu", -17676); SpellMap.put ("Hua", -17496); SpellMap.put ("Huai", -17487); SpellMap.put ("huan", -17482); SpellMap.put ("Huang", -17468); SpellMap.put ("Hui", -17454); SpellMap.put ("Hun", -17433); SpellMap.put ("Huo", -17427); SpellMap.put ("Ji", -17417); SpellMap.put ("JIA", -17202); SpellMap.put ("Jian", -17185); SpellMap.put ("Jiang", -16983); SpellMap.put ("Jiao", -16970); SpellMap.put ("Jie", -16942); SpellMap.put ("Jin", -16915); SpellMap.put ("Jing", -16733); SpellMap.put ("Jiong", -16708); SpellMap.put ("jiu", -16706); SpellMap.put ("JU", -16689); SpellMap.put ("Juan", -16664); SpellMap.put ("Jue", -16657); SpellMap.put ("Jun", -16647); spellmap.put ("ka", -16474); spellmap.put ("kai", -16470); spellmap.put ("kan", -16465); SpellMap.put ("Kang", -16459); SpellMap.put ("Kao", -16452); spellmap.put ("ke", -16448); SpellMap.put ("Ken", -16433); SpellMap.put ("Keng", -16429); SpellMap.put ("Kong", -16427); spellmap.put ("kou", -16423); SpellMap.put ("Ku", -16419); SpellMap.put ("Kua", -16412); SpellMap.put ("Kuai", -16407); SpellMap.put ("Kuan", -16403); SpellMap.put ("Kuang", -16401); SpellMap.put ("Kui", -16393); spellmap.put ("kun", -16220); SpellMap.put ("Kuo", -16216); SpellMap.put ("LA", -16212); SpellMap.put ("Lai", -16205); spellmap.put ("lan", -16202); SpellMap.put ("lang", -16187); SpellMap.put ("Lao", -16180); SpellMap.put ("LE", -16171); SpellMap.put ("lei", -16169); SpellMap.put ("Leng", -16158); spellmap.put ("li", -16155); spellmap.put ("lia", -15959); SpellMap.put ("Lian", -15958); SpellMap.put ("liang", -15944); SpellMap.put ("liao", -15933); spellmap.put ("mentir", -15920); SpellMap.put ("Lin", -15915); spellmap.put ("ling", -15903); SpellMap.put ("Liu", -15889); SpellMap.put ("Long", -15878); SpellMap.put ("Lou", -15707); SpellMap.put ("Lu", -15701); spellmap.put ("lv", -15681); SpellMap.put ("Luan", -15667); spellmap.put ("lue", -15661); spellmap.put ("lun", -15659); SpellMap.put ("Luo", -15652); spellmap.put ("ma", -15640); SpellMap.put ("Mai", -15631); spellmap.put ("hombre", -15625); spellmap.put ("mang", -15454); SpellMap.put ("Mao", -15448); spellmap.put ("yo", -15436); spellmap.put ("mei", -15435); spellmap.put ("hombres", -15419); SpellMap.put ("Meng", -15416); SpellMap.put ("MI", -15408); SpellMap.put ("Mian", -15394); SpellMap.put ("Miao", -15385); SpellMap.put ("Mie", -15377); SpellMap.put ("Min", -15375); SpellMap.put ("Ming", -15369); SpellMap.put ("MIU", -15363); spellmap.put ("Mo", -15362); SpellMap.put ("mou", -15183); SpellMap.put ("Mu", -15180); spellmap.put ("na", -15165); spellmap.put ("nai", -15158); spellmap.put ("nan", -15153); SpellMap.put ("Nang", -15150); SpellMap.put ("Nao", -15149); spellmap.put ("ne", -15144); SpellMap.put ("Nei", -15143); spellmap.put ("nen", -15141); SpellMap.put ("Neng", -15140); spellmap.put ("ni", -15139); SpellMap.put ("Nian", -15128); SpellMap.put ("Niang", -15121); SpellMap.put ("Niao", -15119); SpellMap.put ("Nie", -15117); spellmap.put ("nin", -15110); spellmap.put ("ning", -15109); spellmap.put ("niu", -14941); SpellMap.put ("Nong", -14937); spellmap.put ("nu", -14933); SpellMap.put ("NV", -14930); SpellMap.put ("Nuan", -14929); SpellMap.put ("nue", -14928); SpellMap.put ("NUO", -14926); SpellMap.put ("'O", -14922); spellmap.put ("'ou", -14921); SpellMap.put ("PA", -14914); SpellMap.put ("PAI", -14908); SpellMap.put ("Pan", -14902); SpellMap.put ("Pang", -14894); SpellMap.put ("PAO", -14889); SpellMap.put ("PEI", -14882); SpellMap.put ("Pen", -14873); SpellMap.put ("Peng", -14871); SpellMap.put ("Pi", -14857); SpellMap.put ("Pian", -14678); SpellMap.put ("Piao", -14674); spellmap.put ("pastel", -14670); spellmap.put ("pin", -14668); spellmap.put ("ping", -14663); SpellMap.put ("PO", -14654); SpellMap.put ("PU", -14645); SpellMap.put ("Qi", -14630); SpellMap.put ("Qia", -14594); SpellMap.put ("Qian", -14429); SpellMap.put ("Qiang", -14407); SpellMap.put ("Qiao", -14399); SpellMap.put ("Qie", -14384); SpellMap.put ("Qin", -14379); SpellMap.put ("Qing", -14368); SpellMap.put ("Qiong", -14355); SpellMap.put ("Qiu", -14353); SpellMap.put ("Qu", -14345); spellmap.put ("quan", -14170); spellmap.put ("que", -14159); SpellMap.put ("QUN", -14151); spellmap.put ("ran", -14149); SpellMap.put ("Rang", -14145); SpellMap.put ("Rao", -14140); spellmap.put ("re", -14137); SpellMap.put ("Ren", -14135); SpellMap.put ("Reng", -14125); spellmap.put ("ri", -14123); SpellMap.put ("Rong", -14122); SpellMap.put ("Rou", -14112); SpellMap.put ("Ru", -14109); SpellMap.put ("Ruan", -14099); SpellMap.put ("Rui", -14097); SpellMap.put ("Run", -14094); SpellMap.put ("Ruo", -14092); SpellMap.put ("SA", -14090); spellmap.put ("sai", -14087); SpellMap.put ("SAN", -14083); SpellMap.put ("Sang", -13917); spellmap.put ("sao", -13914); SpellMap.put ("SE", -13910); SpellMap.put ("sen", -13907); SpellMap.put ("Seng", -13906); SpellMap.put ("Sha", -13905); SpellMap.put ("Shai", -13896); spellmap.put ("shan", -13894); spellmap.put ("shang", -13878); SpellMap.put ("Shao", -13870); SpellMap.put ("Ella", -13859); spellmap.put ("shen", -13847); spellmap.put ("sheng", -13831); spellmap.put ("shi", -13658); spellmap.put ("shou", -13611); spellmap.put ("shu", -13601); SpellMap.put ("shua", -13406); spellmap.put ("shuai", -13404); spellmap.put ("shuan", -13400); SpellMap.put ("shuang", -13398); SpellMap.put ("shui", -13395); spellmap.put ("shun", -13391); SpellMap.put ("shuo", -13387); SpellMap.put ("Si", -13383); SpellMap.put ("Song", -13367); spellmap.put ("sou", -13359); SpellMap.put ("SU", -13356); SpellMap.put ("Suan", -13343); spellmap.put ("sui", -13340); SpellMap.put ("Sun", -13329); spellmap.put ("suo", -13326); SpellMap.put ("TA", -13318); SpellMap.put ("Tai", -13147); SpellMap.put ("Tan", -13138); SpellMap.put ("Tang", -13120); SpellMap.put ("Tao", -13107); SpellMap.put ("TE", -13096); SpellMap.put ("Teng", -13095); SpellMap.put ("Ti", -13091); SpellMap.put ("Tian", -13076); SpellMap.put ("Tiao", -13068); SpellMap.put ("Vie", -13063); spellmap.put ("ting", -13060); SpellMap.put ("Tong", -12888); SpellMap.put ("Tou", -12875); SpellMap.put ("Tu", -12871); SpellMap.put ("Tuan", -12860); spellmap.put ("Tui", -12858); spellmap.put ("tun", -12852); SpellMap.put ("Tuo", -12849); spellmap.put ("wa", -12838); spellmap.put ("wai", -12831); spellmap.put ("wan", -12829); spellmap.put ("wang", -12812); spellmap.put ("wei", -12802); spellmap.put ("wen", -12607); SpellMap.put ("Weng", -12597); spellmap.put ("wo", -12594); spellmap.put ("wu", -12585); spellmap.put ("xi", -12556); SpellMap.put ("Xia", -12359); spellmap.put ("xian", -12346); SpellMap.put ("Xiang", -12320); SpellMap.put ("Xiao", -12300); spellmap.put ("xie", -12120); SpellMap.put ("Xin", -12099); spellmap.put ("xing", -12089); spellmap.put ("xiong", -12074); spellmap.put ("xiu", -12067); SpellMap.put ("Xu", -12058); SpellMap.put ("Xuan", -12039); SpellMap.put ("Xue", -11867); spellmap.put ("xun", -11861); SpellMap.put ("Ya", -11847); spellmap.put ("yan", -11831); spellmap.put ("yang", -11798); SpellMap.put ("Yao", -11781); SpellMap.put ("Ye", -11604); SpellMap.put ("Yi", -11589); spellmap.put ("yin", -11536); SpellMap.put ("Ying", -11358); spellmap.put ("yo", -11340); SpellMap.put ("Yong", -11339); SpellMap.put ("You", -11324); SpellMap.put ("Yu", -11303); SpellMap.put ("yuan", -11097); SpellMap.put ("Yue", -11077); spellmap.put ("yun", -11067); spellmap.put ("za", -11055); SpellMap.put ("Zai", -11052); spellmap.put ("zan", -11045); SpellMap.put ("Zang", -11041); spellmap.put ("zao", -11038); SpellMap.put ("Ze", -11024); SpellMap.put ("Zei", -11020); SpellMap.put ("Zen", -11019); SpellMap.put ("Zeng", -11018); SpellMap.put ("Zha", -11014); SpellMap.put ("Zhai", -10838); SpellMap.put ("Zhan", -10832); SpellMap.put ("Zhang", -10815); SpellMap.put ("Zhao", -10800); SpellMap.put ("Zhe", -10790); SpellMap.put ("Zhen", -10780); SpellMap.put ("Zheng", -10764); SpellMap.put ("Zhi", -10587); SpellMap.put ("Zhong", -10544); SpellMap.put ("Zhou", -10533); SpellMap.put ("Zhu", -10519); SpellMap.put ("Zhua", -10331); SpellMap.put ("Zhuai", -10329); SpellMap.put ("Zhuan", -10328); SpellMap.put ("Zhuang", -10322); SpellMap.put ("Zhui", -10315); SpellMap.put ("Zhun", -10309); SpellMap.put ("Zhuo", -10307); SpellMap.put ("Zi", -10296); SpellMap.put ("Zong", -10281); SpellMap.put ("Zou", -10274); SpellMap.put ("Zu", -10270); SpellMap.put ("Zuan", -10262); SpellMap.put ("Zui", -10260); SpellMap.put ("Zun", -10256); SpellMap.put ("Zuo", -10254); } /** * 添加生僻字 * @param cnword 生僻字 * @param hechizo 生僻字的拼音, 如果拼音以 a, o, e 开头 , 请将开头分别改为 'a,' o, 'e , :安 ('an) */ public static void putuncommonword (char cnword, string hechizo) {poco comúnwordsmap.put (cnword, hechizo); } / ** * 初始化生僻字 * / private static void initionuncommonwords () {putuncommonword ('', "ao"); putuncommonword ('灞', "ba"); putuncommonword ('', "ben"); putuncommonword ('', "biao"); putuncommonword ('', "biao"); putuncommonword ('杈', "cha"); putuncommonword ('', "chen"); putuncommonword ('', "cheng"); putuncommonword ('魑', "chi"); putuncommonword ('', "chong"); putuncommonword ('', "chong"); putuncommonword ('', "cu"); putuncommonword ('毳', "Cui"); putuncommonword ('', "Fang"); putuncommonword ('沣', "feng"); putuncommonword ('', "gou"); putuncommonword ('焓', "Han"); putuncommonword ('', "Han"); putuncommonword ('晗', "Han"); putuncommonword ('', "Han"); putuncommonword ('翮', "él"); putuncommonword ('', "él"); putuncommonword ('', "huan"); putuncommonword ('', "hui"); putuncommonword ('', "jie"); putuncommonword ('', "jing"); putuncommonword ('', "jing"); putuncommonword ('', "jing"); putuncommonword ('', "kun"); putuncommonword ('琨', "kun"); putuncommonword ('', "kun"); putuncommonword ('骊', "li"); putuncommonword ('鎏', "liu"); putuncommonword ('', "hombre"); putuncommonword ('', "mei"); putuncommonword ('淼', "Miao"); putuncommonword ('', "nan"); putuncommonword ('', "nan"); putuncommonword ('甯', "ning"); putuncommonword ('', "ning"); putuncommonword ('', "pa"); putuncommonword ('', "pi"); putuncommonword ('', "qian"); putuncommonword ('', "qin"); putuncommonword ('', "qing"); putuncommonword ('', "qing"); putuncommonword ('', "qing"); putuncommonword ('', "qing"); putuncommonword ('', "qing"); putuncommonword ('悫', "que"); putuncommonword ('', "que"); putuncommonword ('', "rong"); putuncommonword ('', "shen"); putuncommonword ('', "shen"); putuncommonword ('', "shen"); putuncommonword ('', "sheng"); putuncommonword ('', "sheng"); putuncommonword ('晟', "sheng"); putuncommonword ('', "sheng"); putuncommonword ('眚', "sheng"); putuncommonword ('', "sheng"); putuncommonword ('', "sheng"); putuncommonword ('', "sheng"); putuncommonword ('', "sheng"); putuncommonword ('', "shi"); putuncommonword ('', "su"); putuncommonword ('', "tao"); putuncommonword ('', "Tian"); putuncommonword ('仝', "tong"); putuncommonword ('', "wei"); putuncommonword ('炜', "wei"); putuncommonword ('玮', "wei"); putuncommonword ('', "wu"); putuncommonword ('邬', "wu"); putuncommonword ('', "xi"); putuncommonword ('', "xian"); putuncommonword ('', "xiao"); putuncommonword ('', "xiao"); putuncommonword ('筱', "xiao"); putuncommonword ('勰', "xie"); putuncommonword ('忻', "xin"); putuncommonword ('庥', "xiu"); putuncommonword ('', "xu"); putuncommonword ('', "xu"); putuncommonword ('', "xu"); putuncommonword ('', "xuan"); putuncommonword ('煊', "xuan"); putuncommonword ('', "xuan"); putuncommonword ('', "xuan"); putuncommonword ('暄', "xuan"); putuncommonword ('娅', "ya"); putuncommonword ('琰', "yan"); putuncommonword ('妍', "yan"); putuncommonword ('焱', "yan"); putuncommonword ('', "yang"); putuncommonword ('', "yang"); putuncommonword ('', "yang"); putuncommonword ('', "yao"); putuncommonword ('', "yao"); putuncommonword ('怡', "yi"); putuncommonword ('', "yi"); putuncommonword ('', "yi"); putuncommonword ('', "yi"); putuncommonword ('瑛', "ying"); putuncommonword ('', "ying"); putuncommonword ('', "ying"); putuncommonword ('', "ying"); putuncommonword ('滢', "ying"); putuncommonword ('', "ying"); putuncommonword ('莜', "usted"); putuncommonword ('昱', "yu"); putuncommonword ('', "yun"); putuncommonword ('', "zhe"); putuncommonword ('', "zhe"); putuncommonword ('', "zhi"); } /*** 获得单个汉字的 ASCII. * @param cn 汉字字符 * @return 汉字对应的 ascii, 错误时返回 0 */ public static int getcnascii (char cn) {byte [] bytes = (string.valueOf (cn)). getBytes (); if (bytes == null || bytes.length == 0 || bytes.length> 2) {// 错误 return 0; } if (bytes.length == 1) {// 英文字符 return bytes [0]; } if (bytes.length == 2) {// 中文字符 int hightbyte = 256 + bytes [0]; int LowByte = 256 + bytes [1]; retorno (256 * Hightbyte + LowByte) - 256 * 256; // 返回 ASCII} return 0; // 错误} /** * 根据 ASCII 码到 Spellmap 中查找对应的拼音 * @param ascii ascii * @return ascii 对应的拼音, 如果 ascii 对应的字符为单字符 则返回对应的单字符 则返回对应的单字符, 如果不是单字符且在 Spellmap 中没找到对应的拼音 , 则返回空字符串 (""), */ public static String getSpellByascii (int ascii) {if (ascii> 0 && ascii <160) {// 单字符 cadena de retorno. valor de ((char) ascii); } if (ASCII <-20319 || ASCII> -10247) {// 不知道的字符 return ""; } String Spell = null; // clave entero asciirang; // Value String SpellPrevious = null; // 用来保存上次轮循环的 clave int asciirangprevious = -20319; // 用来保存上一次循环的 valor para (iterator it = spellmap.keySet (). Iterator (); it.hasnext ();) {spell = (string) it.next (); // 拼音 asciirang = spellmap.get (hechizo); // 拼音的 ascii if (asciirang! = Null) {if (ascii> = asciirangprevious && ascii <asciirang) {// 区间找到, 返回对应的拼音 return (spellPrevious == null)? hechizo: hechizo de hechizo; } else {spellPrevious = hechizo; asciirangprevious = asciirang; } } } devolver ""; } /** * 获取字符串的全拼或首拼, 是汉字则转化为对应的拼音或拼音首字母, 其它字符不进行转换 * @param cnstr 要获取全拼或首拼的字符串 * @param OnlyFirstspell 是否只获取首拼 , 为 为 时 只获取首拼 只获取首拼 , 为 falso 时 获取全拼 获取全拼 * @return string cnstr 的全拼或首拼, 如果 cnstr 为 null 时, 返回 "" */ cadena estática pública getSpell (String CNSTR, boolean soloFirstspell) {if (cnstr == null) {return ""; } char [] chars = cnstr.trim (). toCharArray (); StringBuffer sb = new StringBuffer (); para (int i = 0, len = chars.length; i <len; i ++) {int ascii = getCnascii (chars [i]); if (ascii == 0) {// 如果获取汉字的 ASCII 出错 , 则不进行转换 sb.append (chars [i]); } else {String Spell = GetSpellByascii (ASCII); // 根据 ASCII 取拼音 if (hechizo == null || spell.length () == 0) {// 如果根据 ASCII 取拼音没取到 , 则到生僻字 MAP 中取 Spell = UncomMonwordSmap.get (chars [ i]); } if (hechizo == null || spell.length () == 0) {// 如果没有取到对应的拼音 , 则不做转换 , 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 追加原字符 poco aMomonwordSmap.get (chars [i]); } else {if (OnlyFirstSpell) {sb.append (spell.startswith ("'")? Spell.substring (1, 2): Spell.substring (0, 1)); } else {sb.append (hechizo); }}}} // Fin de para return sb.ToString (); } public static void main (string [] args) {string [] s = {"获取汉字全拼和首拼测试", "Esta es una prueba", "a, b; c [d]", "标 标 标 标 标 标 标 标 标 标点。 "," 圆角数字123 , 特殊符号・¥%"... ...", "繁体字 : 西安", "西安", "山"}; for (int i = 0; i <s.length; i ++) {long l1 = system.currentTimemillis (); System.out.println (s [i] + "的全拼:" + getSpell (s [i], falso)); System.out.println (s [i] + "的首拼:" + getSpell (s [i], true)); System.out.println ("获取全拼和首拼 共 用了"+(System.CurrentTimemillis ()-L1)+"毫秒/n"); }}}