استيراد java.util.collections ؛ استيراد java.util.iterator ؛ استيراد java.util.linkedhashmap ؛ استيراد java.util.map ؛ / ** * 将汉字转化为全拼 */ public class cntospell1 {private static map <string ، integer> spellmap = null ؛ // 存放生僻字和其拼音的 خريطة الخريطة الثابتة الخاصة <حرف ، سلسلة> UncomonwordSmap = null ؛ ثابت {if (spellmap == null) {spellmap = collections.synchronizedMap (New LinkedHashMap <string ، integer> (396)) ؛ UncomonwordSmap = collections.synchronizedMap (New LinkedHashMap <farter ، string> (200)) ؛ } تهيئة () ؛ initUNCommonwords () ؛ } private cntospell1 () {} / ** * 初始化 * / private static void initialize () {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 ("دان" ، -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 ("Dio" ، -18961) ؛ spellmap.put ("Die" ، -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 ("المروحة" ، -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 ("العصابة" ، -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 ("قوانغ" ، -17950) ؛ spellmap.put ("واجهة المستخدم الرسومية" ، -17947) ؛ spellmap.put ("Gun" ، -17931) ؛ spellmap.put ("guo" ، -17928) ؛ spellmap.put ("ha" ، -17922) ؛ spellmap.put ("Hai" ، -17759) ؛ spellmap.put ("Han" ، -17752) ؛ spellmap.put ("شنق" ، -17733) ؛ spellmap.put ("hao" ، -17730) ؛ spellmap.put ("He" ، -17721) ؛ spellmap.put ("Hei" ، -17703) ؛ spellmap.put ("Hen" ، -17701) ؛ spellmap.put ("Heng" ، -17697) ؛ spellmap.put ("هونغ" ، -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 ("كين" ، -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 ("لاو" ، -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 ("الكذب" ، -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 ("man" ، -15625) ؛ spellmap.put ("Mang" ، -15454) ؛ spellmap.put ("mao" ، -15448) ؛ spellmap.put ("Me" ، -15436) ؛ spellmap.put ("mei" ، -15435) ؛ spellmap.put ("الرجال" ، -15419) ؛ spellmap.put ("منغ" ، -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 ("مذكرة التفاهم" ، -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 ("نيان" ، -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 ("PIE" ، -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 ("سين" ، -13907) ؛ spellmap.put ("Seng" ، -13906) ؛ spellmap.put ("sha" ، -13905) ؛ spellmap.put ("Shai" ، -13896) ؛ spellmap.put ("شان" ، -13894) ؛ spellmap.put ("Shang" ، -13878) ؛ spellmap.put ("Shao" ، -13870) ؛ spellmap.put ("She" ، -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 ("TIE" ، -13063) ؛ spellmap.put ("Ting" ، -13060) ؛ spellmap.put ("تونغ" ، -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 spear 生僻字的拼音 ، 如果拼音以 a ، o ، e 开头 请将开头分别改为 请将开头分别改为 ، 'o ،' e , 如 :安 ('an) */ public static void putUncommonword (char cnword ، string fell) {unmonwordsmap.put (cnword ، spell) ؛ } / ** * 初始化生僻字 * / private static void inituncommonwords () {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 ('翮' ، "He") ؛ putUncommonword ('' ، "He") ؛ putUncommonword ('' ، "huan") ؛ putUncommonword ('' ، "hui") ؛ putUncommonword ('' ، "jie") ؛ putUncommonword ('' ، "Jing") ؛ putUncommonword ('' ، "Jing") ؛ putUncommonword ('' ، "Jing") ؛ putUncommonword ('' ، "kun") ؛ putUncommonword ('琨' ، "kun") ؛ putUncommonword ('' ، "kun") ؛ putUncommonword ('骊' ، "li") ؛ putUncommonword ('鎏' ، "liu") ؛ putUncommonword ('' ، "man") ؛ 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 ('莜' ، "you") ؛ 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] ؛ Return (256 * Hightbyte + Lowbyte) - 256 * 256 ؛ // 返回 ascii} return 0 ؛ // 错误 ستر字符且在 spellmap 中没找到对应的拼音 , 则返回空字符串 ("") ، */ السلسلة الثابتة العامة getSpellbyascii (int ascii) {if (ascii> 0 && ascii <160) {// 单字符 string return. valueof ((char) ascii) ؛ } if (ASCII <-20319 || ASCII> -10247) {// 不知道的字符 return "" ؛ } سلسلة تعويذة = فارغة ؛ // key integer asciirang ؛ // Value String Spellprevious = null ؛ // 用来保存上次轮循环的 Key int asciirangprevious = -20319 ؛ // 用来保存上一次循环的 قيمة (iterator it = spellmap.keyset (). iterator () ؛ it.hasnext () ؛) {spell = (string) it.next () ؛ // 拼音 asciirang = spellmap.get (تعويذة) ؛ // 拼音的 ascii if (asciirang! = null) {if (ascii> = asciirangprevious && ascii <asciirang) {// 区间找到 ، 返回对应的拼音 return (spellprevious == null)؟ تعويذة: Spellprevious ؛ } آخر {spellprevious = spell ؛ Asciirangprevious = Asciirang ؛ } } } يعود ""؛ } /** * 获取字符串的全拼或首拼 ، 是汉字则转化为对应的拼音或拼音首字母 ، 其它字符不进行转换 * param cnstr 要获取全拼或首拼的字符串 * param فقط firstspell 是否只获取首拼 , 为 为 时 , 只获取首拼 只获取首拼 , 为 false 时 时 获取全拼 获取全拼 * @ (String cnstr ، boolean onlyfirstspell) {if (cnstr == null) {return "" ؛ } char [] chars = cnstr.trim (). tochararray () ؛ StringBuffer SB = New StringBuffer () ؛ لـ (int i = 0 ، len = chars.length ؛ i <len ؛ i ++) {int ascii = getCnascii (chars [i]) ؛ if (ascii == 0) {// 如果获取汉字的 ascii 出错 , 则不进行转换 sb.append (chars [i]) ؛ } آخر {string spell = getSpellbyascii (ASCII) ؛ // 根据 ascii 取拼音 if (spell == null || spell.length () == 0) {// 如果根据 ascii 取拼音没取到 则到生僻字 则到生僻字 map 中取 spell = uncomonwordsmap.get (chars [chars [ أنا])؛ } if (spell == null || spell.length () == 0) {// 如果没有取到对应的拼音 , 则不做转换 , 追加原字符 spell = uncomonwordsmap.get (chars [i]) ؛ } آخر {if (omesfirstspell) {sb.append (spell.startswith ("'')؟ spell.substring (1 ، 2): spell.substring (0 ، 1)) ؛ } آخر {sb.append (spell) ؛ }}}} // end of for return sb.toString () ؛ } main static void main (string [] args) {string [] s = {"获取汉字全拼和首拼测试" ، "هذا اختبار" ، "a ، b ؛ c [d] ،" 标 ,点。 "،" 圆角数字123 , 特殊符号・¥ ٪ - ― ....... "،" 繁体字 : : "،" 西安 "،" 山 "} ؛ لـ (int i = 0 ؛ i <s.length ؛ i ++) {long l1 = system.currentTimeMillis () ؛ system.out.println (s [i] + "的全拼:" + getSpell (s [i] ، false)) ؛ System.out.println (s [i] + "的首拼:" + getSpell (s [i] ، true)) ؛ System.out.println ("获取全拼和首拼 共 用了"+(System.CurrentTimeMillis ()-L1)+"毫秒/n") ؛ }}}