oracle汉字转拼音函数
Oracle汉字生成拼音码的函数

Oracle汉字⽣成拼⾳码的函数函数:CREATE OR REPLACE FUNCTION fgetpy (v_str VARCHAR2)RETURN VARCHAR2ASv_strlen INT;v_return VARCHAR2 (500);v_ii INT;v_n INT;v_c VARCHAR2 (2);v_chn VARCHAR2 (2);v_rc VARCHAR2 (500);/*************************************************************************⽣成汉字拼⾳码的函数。
2009-06-21**************************************************************************/BEGIN--dbms_output.put_line(v_str);v_rc := v_str;v_strlen := LENGTH (v_rc);v_return := '';v_ii := 0;WHILE v_ii < v_strlenLOOPv_ii := v_ii + 1;v_n := 63;SELECT SUBSTR (v_rc, v_ii, 1)INTO v_chnFROM DUAL;SELECT v_n + MAX (rowsf)INTO v_nFROM (SELECT chn, ROWNUM rowsfFROM (SELECT chnFROM (SELECT '吖' chnFROM DUALUNIONSELECT '⼋'FROM DUALUNION ALLSELECT '嚓'FROM DUALUNION ALLSELECT '咑'FROM DUALUNION ALLSELECT '妸'FROM DUALUNION ALLSELECT '发'FROM DUALUNION ALLSELECT '旮'FROM DUALUNION ALLSELECT '铪'FROM DUALUNION ALLSELECT '丌'FROM DUAL --because have no 'i'UNION ALLSELECT '丌'FROM DUALUNION ALLSELECT '咔'FROM DUALUNION ALLSELECT '垃'FROM DUALUNION ALLSELECT '嘸'FROM DUALUNION ALLSELECT '拏'FROM DUALUNION ALLSELECT '噢'FROM DUALUNION ALLSELECT '妑'FROM DUALUNION ALLSELECT '七'FROM DUALUNION ALLSELECT '呥'FROM DUALUNION ALLSELECT '仨'FROM DUALUNION ALLSELECT '他'FROM DUALUNION ALLSELECT '屲'FROM DUALUNION ALLSELECT '屲'FROM DUALUNION ALLSELECT '屲'FROM DUALUNION ALLSELECT '⼣'FROM DUALUNION ALLSELECT '丫'FROM DUALUNION ALLSELECT '帀'FROM DUALUNION ALLSELECT v_chnFROM DUAL) aORDER BY NLSSORT (chn, 'NLS_SORT=SCHINESE_PINYIN_M')) c) b WHERE chn = v_chn;v_c := CHR (v_n);IF CHR (v_n) = '@'THEN --英⽂直接返回v_c := v_chn;END IF;v_return := v_return || v_c;v_return := lower(v_return);END LOOP;RETURN v_return;END fgetpy; Oracle汉字⽣成拼⾳函数。
ORACLE汉字转拼音

方法/步骤11.启动Excel 2003(其它版本请仿照操作),打开相应的工作表;22.执行“工具→宏→Visual Basic编辑器”命令(或者直接按“Alt+F11”组合键),进入Visual Basic 编辑状态;33.执行“插入→模块”命令,插入一个新模块。
再双击插入的模块,进入模块代码编辑状态;44.将代码输入其中;Function pinyin(p As String) As Stringi = Asc(p)Select Case iCase -20319 To -20318: pinyin = "a "Case -20317 To -20305: pinyin = "ai "Case -20304 To -20296: pinyin = "an "Case -20295 To -20293: pinyin = "ang "Case -20292 To -20284: pinyin = "ao "Case -20283 To -20266: pinyin = "ba "Case -20265 To -20258: pinyin = "bai "Case -20257 To -20243: pinyin = "ban "Case -20242 To -20231: pinyin = "bang "Case -20230 To -20052: pinyin = "bao "Case -20051 To -20037: pinyin = "bei "Case -20036 To -20033: pinyin = "ben "Case -20032 To -20027: pinyin = "beng "Case -20026 To -20003: pinyin = "bi "Case -20002 To -19991: pinyin = "bian "Case -19990 To -19987: pinyin = "biao "Case -19986 To -19983: pinyin = "bie "Case -19982 To -19977: pinyin = "bin "Case -19976 To -19806: pinyin = "bing "Case -19805 To -19785: pinyin = "bo "Case -19784 To -19776: pinyin = "bu "Case -19775 To -19775: pinyin = "ca "Case -19774 To -19764: pinyin = "cai "Case -19763 To -19757: pinyin = "can "Case -19756 To -19752: pinyin = "cang "Case -19751 To -19747: pinyin = "cao "Case -19746 To -19742: pinyin = "ce "Case -19741 To -19740: pinyin = "ceng "Case -19739 To -19729: pinyin = "cha "Case -19728 To -19726: pinyin = "chai "Case -19715 To -19541: pinyin = "chang " Case -19540 To -19532: pinyin = "chao " Case -19531 To -19526: pinyin = "che " Case -19525 To -19516: pinyin = "chen " Case -19515 To -19501: pinyin = "cheng " Case -19500 To -19485: pinyin = "chi " Case -19484 To -19480: pinyin = "chong " Case -19479 To -19468: pinyin = "chou " Case -19467 To -19290: pinyin = "chu " Case -19289 To -19289: pinyin = "chuai " Case -19288 To -19282: pinyin = "chuan " Case -19281 To -19276: pinyin = "chuang " Case -19275 To -19271: pinyin = "chui " Case -19270 To -19264: pinyin = "chun " Case -19263 To -19262: pinyin = "chuo " Case -19261 To -19250: pinyin = "ci " Case -19249 To -19244: pinyin = "cong " Case -19243 To -19243: pinyin = "cou " Case -19242 To -19239: pinyin = "cu " Case -19238 To -19236: pinyin = "cuan " Case -19235 To -19228: pinyin = "cui " Case -19227 To -19225: pinyin = "cun " Case -19224 To -19219: pinyin = "cuo " Case -19218 To -19213: pinyin = "da " Case -19212 To -19039: pinyin = "dai " Case -19038 To -19024: pinyin = "dan " Case -19023 To -19019: pinyin = "dang " Case -19018 To -19007: pinyin = "dao " Case -19006 To -19004: pinyin = "de " Case -19003 To -18997: pinyin = "deng " Case -18996 To -18978: pinyin = "di " Case -18977 To -18962: pinyin = "dian " Case -18961 To -18953: pinyin = "diao " Case -18952 To -18784: pinyin = "die " Case -18783 To -18775: pinyin = "ding " Case -18774 To -18774: pinyin = "diu " Case -18773 To -18527: pinyin = "dong " Case -18526 To -18519: pinyin = "fa " Case -18518 To -18502: pinyin = "fan " Case -18501 To -18491: pinyin = "fang " Case -18490 To -18479: pinyin = "fei " Case -18478 To -18464: pinyin = "fen " Case -18463 To -18449: pinyin = "feng "Case -18447 To -18447: pinyin = "fou " Case -18446 To -18240: pinyin = "fu " Case -18239 To -18238: pinyin = "ga " Case -18237 To -18232: pinyin = "gai " Case -18231 To -18221: pinyin = "gan " Case -18220 To -18212: pinyin = "gang " Case -18211 To -18202: pinyin = "gao " Case -18201 To -18185: pinyin = "ge " Case -18184 To -18184: pinyin = "gei " Case -18183 To -18182: pinyin = "gen " Case -18181 To -18013: pinyin = "geng " Case -18012 To -17998: pinyin = "gong " Case -17997 To -17989: pinyin = "gou " Case -17988 To -17971: pinyin = "gu " Case -17970 To -17965: pinyin = "gua " Case -17964 To -17962: pinyin = "guai " Case -17961 To -17951: pinyin = "guan " Case -17950 To -17948: pinyin = "guang " Case -17947 To -17932: pinyin = "gui " Case -17931 To -17929: pinyin = "gun " Case -17928 To -17923: pinyin = "guo " Case -17922 To -17760: pinyin = "ha " Case -17759 To -17753: pinyin = "hai " Case -17752 To -17734: pinyin = "han " Case -17733 To -17731: pinyin = "hang " Case -17730 To -17722: pinyin = "hao " Case -17721 To -17704: pinyin = "he " Case -17703 To -17702: pinyin = "hei " Case -17701 To -17698: pinyin = "hen " Case -17697 To -17693: pinyin = "heng " Case -17692 To -17684: pinyin = "hong " Case -17683 To -17677: pinyin = "hou " Case -17676 To -17497: pinyin = "hu " Case -17496 To -17488: pinyin = "hua " Case -17487 To -17483: pinyin = "huai " Case -17482 To -17469: pinyin = "huan " Case -17468 To -17455: pinyin = "huang " Case -17454 To -17434: pinyin = "hui " Case -17433 To -17428: pinyin = "hun " Case -17427 To -17418: pinyin = "huo " Case -17417 To -17203: pinyin = "ji " Case -17202 To -17186: pinyin = "jia " Case -17185 To -16984: pinyin = "jian "Case -16970 To -16943: pinyin = "jiao " Case -16942 To -16916: pinyin = "jie " Case -16915 To -16734: pinyin = "jin " Case -16733 To -16709: pinyin = "jing " Case -16708 To -16707: pinyin = "jiong " Case -16706 To -16690: pinyin = "jiu " Case -16689 To -16665: pinyin = "ju " Case -16664 To -16658: pinyin = "juan " Case -16657 To -16648: pinyin = "jue " Case -16647 To -16475: pinyin = "jun " Case -16474 To -16471: pinyin = "ka " Case -16470 To -16466: pinyin = "kai " Case -16465 To -16460: pinyin = "kan " Case -16459 To -16453: pinyin = "kang " Case -16452 To -16449: pinyin = "kao " Case -16448 To -16434: pinyin = "ke " Case -16433 To -16430: pinyin = "ken " Case -16429 To -16428: pinyin = "keng " Case -16427 To -16424: pinyin = "kong " Case -16423 To -16420: pinyin = "kou " Case -16419 To -16413: pinyin = "ku " Case -16412 To -16408: pinyin = "kua " Case -16407 To -16404: pinyin = "kuai " Case -16403 To -16402: pinyin = "kuan " Case -16401 To -16394: pinyin = "kuang " Case -16393 To -16221: pinyin = "kui " Case -16220 To -16217: pinyin = "kun " Case -16216 To -16213: pinyin = "kuo " Case -16212 To -16206: pinyin = "la " Case -16205 To -16203: pinyin = "lai " Case -16202 To -16188: pinyin = "lan " Case -16187 To -16181: pinyin = "lang " Case -16180 To -16172: pinyin = "lao " Case -16171 To -16170: pinyin = "le " Case -16169 To -16159: pinyin = "lei " Case -16158 To -16156: pinyin = "leng " Case -16155 To -15960: pinyin = "li " Case -15959 To -15959: pinyin = "lia " Case -15958 To -15945: pinyin = "lian " Case -15944 To -15934: pinyin = "liang " Case -15933 To -15921: pinyin = "liao " Case -15920 To -15916: pinyin = "lie " Case -15915 To -15904: pinyin = "lin "Case -15889 To -15879: pinyin = "liu " Case -15878 To -15708: pinyin = "long " Case -15707 To -15702: pinyin = "lou " Case -15701 To -15682: pinyin = "lu " Case -15681 To -15668: pinyin = "lv " Case -15667 To -15662: pinyin = "luan " Case -15661 To -15660: pinyin = "lue " Case -15659 To -15653: pinyin = "lun " Case -15652 To -15641: pinyin = "luo " Case -15640 To -15632: pinyin = "ma " Case -15631 To -15626: pinyin = "mai " Case -15625 To -15455: pinyin = "man " Case -15454 To -15449: pinyin = "mang " Case -15448 To -15437: pinyin = "mao " Case -15436 To -15436: pinyin = "me " Case -15435 To -15420: pinyin = "mei " Case -15419 To -15417: pinyin = "men " Case -15416 To -15409: pinyin = "meng " Case -15408 To -15395: pinyin = "mi " Case -15394 To -15386: pinyin = "mian " Case -15385 To -15378: pinyin = "miao " Case -15377 To -15376: pinyin = "mie " Case -15375 To -15370: pinyin = "min " Case -15369 To -15364: pinyin = "ming " Case -15363 To -15363: pinyin = "miu " Case -15362 To -15184: pinyin = "mo " Case -15183 To -15181: pinyin = "mou " Case -15180 To -15166: pinyin = "mu " Case -15165 To -15159: pinyin = "na " Case -15158 To -15154: pinyin = "nai " Case -15153 To -15151: pinyin = "nan " Case -15150 To -15150: pinyin = "nang " Case -15149 To -15145: pinyin = "nao " Case -15144 To -15144: pinyin = "ne " Case -15143 To -15142: pinyin = "nei " Case -15141 To -15141: pinyin = "nen " Case -15140 To -15140: pinyin = "neng " Case -15139 To -15129: pinyin = "ni " Case -15128 To -15122: pinyin = "nian " Case -15121 To -15120: pinyin = "niang " Case -15119 To -15118: pinyin = "niao " Case -15117 To -15111: pinyin = "nie " Case -15110 To -15110: pinyin = "nin "Case -14941 To -14938: pinyin = "niu " Case -14937 To -14934: pinyin = "nong " Case -14933 To -14931: pinyin = "nu " Case -14930 To -14930: pinyin = "nv " Case -14929 To -14929: pinyin = "nuan " Case -14928 To -14927: pinyin = "nue " Case -14926 To -14923: pinyin = "nuo " Case -14922 To -14922: pinyin = "o " Case -14921 To -14915: pinyin = "ou " Case -14914 To -14909: pinyin = "pa " Case -14908 To -14903: pinyin = "pai " Case -14902 To -14895: pinyin = "pan " Case -14894 To -14890: pinyin = "pang " Case -14889 To -14883: pinyin = "pao " Case -14882 To -14874: pinyin = "pei " Case -14873 To -14872: pinyin = "pen " Case -14871 To -14858: pinyin = "peng " Case -14857 To -14679: pinyin = "pi " Case -14678 To -14675: pinyin = "pian " Case -14674 To -14671: pinyin = "piao " Case -14670 To -14669: pinyin = "pie " Case -14668 To -14664: pinyin = "pin " Case -14663 To -14655: pinyin = "ping " Case -14654 To -14646: pinyin = "po " Case -14645 To -14631: pinyin = "pu " Case -14630 To -14595: pinyin = "qi " Case -14594 To -14430: pinyin = "qia " Case -14429 To -14408: pinyin = "qian " Case -14407 To -14400: pinyin = "qiang " Case -14399 To -14385: pinyin = "qiao " Case -14384 To -14380: pinyin = "qie " Case -14379 To -14369: pinyin = "qin " Case -14368 To -14356: pinyin = "qing " Case -14355 To -14354: pinyin = "qiong " Case -14353 To -14346: pinyin = "qiu " Case -14345 To -14171: pinyin = "qu " Case -14170 To -14160: pinyin = "quan " Case -14159 To -14152: pinyin = "que " Case -14151 To -14150: pinyin = "qun " Case -14149 To -14146: pinyin = "ran " Case -14145 To -14141: pinyin = "rang " Case -14140 To -14138: pinyin = "rao " Case -14137 To -14136: pinyin = "re "Case -14125 To -14124: pinyin = "reng " Case -14123 To -14123: pinyin = "ri " Case -14122 To -14113: pinyin = "rong " Case -14112 To -14110: pinyin = "rou " Case -14109 To -14100: pinyin = "ru " Case -14099 To -14098: pinyin = "ruan " Case -14097 To -14095: pinyin = "rui " Case -14094 To -14093: pinyin = "run " Case -14092 To -14091: pinyin = "ruo " Case -14090 To -14088: pinyin = "sa " Case -14087 To -14084: pinyin = "sai " Case -14083 To -13918: pinyin = "san " Case -13917 To -13915: pinyin = "sang " Case -13914 To -13911: pinyin = "sao " Case -13910 To -13908: pinyin = "se " Case -13907 To -13907: pinyin = "sen " Case -13906 To -13906: pinyin = "seng " Case -13905 To -13897: pinyin = "sha " Case -13896 To -13895: pinyin = "shai " Case -13894 To -13879: pinyin = "shan " Case -13878 To -13871: pinyin = "shang " Case -13870 To -13860: pinyin = "shao " Case -13859 To -13848: pinyin = "she " Case -13847 To -13832: pinyin = "shen " Case -13831 To -13659: pinyin = "sheng " Case -13658 To -13612: pinyin = "shi " Case -13611 To -13602: pinyin = "shou " Case -13601 To -13407: pinyin = "shu " Case -13406 To -13405: pinyin = "shua " Case -13404 To -13401: pinyin = "shuai " Case -13400 To -13399: pinyin = "shuan " Case -13398 To -13396: pinyin = "shuang " Case -13395 To -13392: pinyin = "shui " Case -13391 To -13388: pinyin = "shun " Case -13387 To -13384: pinyin = "shuo " Case -13383 To -13368: pinyin = "si " Case -13367 To -13360: pinyin = "song " Case -13359 To -13357: pinyin = "sou " Case -13356 To -13344: pinyin = "su " Case -13343 To -13341: pinyin = "suan " Case -13340 To -13330: pinyin = "sui " Case -13329 To -13327: pinyin = "sun " Case -13326 To -13319: pinyin = "suo "Case -13147 To -13139: pinyin = "tai " Case -13138 To -13121: pinyin = "tan " Case -13120 To -13108: pinyin = "tang " Case -13107 To -13097: pinyin = "tao " Case -13096 To -13096: pinyin = "te " Case -13095 To -13092: pinyin = "teng " Case -13091 To -13077: pinyin = "ti " Case -13076 To -13069: pinyin = "tian " Case -13068 To -13064: pinyin = "tiao " Case -13063 To -13061: pinyin = "tie " Case -13060 To -12889: pinyin = "ting " Case -12888 To -12876: pinyin = "tong " Case -12875 To -12872: pinyin = "tou " Case -12871 To -12861: pinyin = "tu " Case -12860 To -12859: pinyin = "tuan " Case -12858 To -12853: pinyin = "tui " Case -12852 To -12850: pinyin = "tun " Case -12849 To -12839: pinyin = "tuo " Case -12838 To -12832: pinyin = "wa " Case -12831 To -12830: pinyin = "wai " Case -12829 To -12813: pinyin = "wan " Case -12812 To -12803: pinyin = "wang " Case -12802 To -12608: pinyin = "wei " Case -12607 To -12598: pinyin = "wen " Case -12597 To -12595: pinyin = "weng " Case -12594 To -12586: pinyin = "wo " Case -12585 To -12557: pinyin = "wu " Case -12556 To -12360: pinyin = "xi " Case -12359 To -12347: pinyin = "xia " Case -12346 To -12321: pinyin = "xian " Case -12320 To -12301: pinyin = "xiang " Case -12300 To -12121: pinyin = "xiao " Case -12120 To -12100: pinyin = "xie " Case -12099 To -12090: pinyin = "xin " Case -12089 To -12075: pinyin = "xing " Case -12074 To -12068: pinyin = "xiong " Case -12067 To -12059: pinyin = "xiu " Case -12058 To -12040: pinyin = "xu " Case -12039 To -11868: pinyin = "xuan " Case -11867 To -11862: pinyin = "xue " Case -11861 To -11848: pinyin = "xun " Case -11847 To -11832: pinyin = "ya " Case -11831 To -11799: pinyin = "yan "Case -11781 To -11605: pinyin = "yao " Case -11604 To -11590: pinyin = "ye " Case -11589 To -11537: pinyin = "yi " Case -11536 To -11359: pinyin = "yin " Case -11358 To -11341: pinyin = "ying " Case -11340 To -11340: pinyin = "yo " Case -11339 To -11325: pinyin = "yong " Case -11324 To -11304: pinyin = "you " Case -11303 To -11098: pinyin = "yu " Case -11097 To -11078: pinyin = "yuan " Case -11077 To -11068: pinyin = "yue " Case -11067 To -11056: pinyin = "yun " Case -11055 To -11053: pinyin = "za " Case -11052 To -11046: pinyin = "zai " Case -11045 To -11042: pinyin = "zan " Case -11041 To -11039: pinyin = "zang " Case -11038 To -11025: pinyin = "zao " Case -11024 To -11021: pinyin = "ze " Case -11020 To -11020: pinyin = "zei " Case -11019 To -11019: pinyin = "zen " Case -11018 To -11015: pinyin = "zeng " Case -11014 To -10839: pinyin = "zha " Case -10838 To -10833: pinyin = "zhai " Case -10832 To -10816: pinyin = "zhan " Case -10815 To -10801: pinyin = "zhang " Case -10800 To -10791: pinyin = "zhao " Case -10790 To -10781: pinyin = "zhe " Case -10780 To -10765: pinyin = "zhen " Case -10764 To -10588: pinyin = "zheng " Case -10587 To -10545: pinyin = "zhi " Case -10544 To -10534: pinyin = "zhong " Case -10533 To -10520: pinyin = "zhou " Case -10519 To -10332: pinyin = "zhu " Case -10331 To -10330: pinyin = "zhua " Case -10329 To -10329: pinyin = "zhuai " Case -10328 To -10323: pinyin = "zhuan " Case -10322 To -10316: pinyin = "zhuang " Case -10315 To -10310: pinyin = "zhui " Case -10309 To -10308: pinyin = "zhun " Case -10307 To -10297: pinyin = "zhuo " Case -10296 To -10282: pinyin = "zi " Case -10281 To -10275: pinyin = "zong " Case -10274 To -10271: pinyin = "zou "Case -10262 To -10261: pinyin = "zuan "Case -10260 To -10257: pinyin = "zui "Case -10256 To -10255: pinyin = "zun "Case -10254 To -10254: pinyin = "zuo "Case Else: pinyin = pEnd SelectEnd FunctionFunction getpy(str)For i = 1 To Len(str)getpy = getpy & pinyin(Mid(str, i, 1))Next iEnd Function55.代码输入完成后,直接关闭Visual Basic编辑窗口,返回Excel编辑状态;66.自定义函数就可以用了,如:选中A2单元格,输入公式:=getpy(A2)。
汉字转换为拼音的代码

'***************************************************************************'* MODULE NAME: HzToPy'* AUTHOR & DATE: tt.t'* 03 Apirl 2007'* DESCRIPTION: 将中文字符串转换为拼音,就这些~'* 有汉字得到拼音其实并不是我很关心的一个问题,只是发现已经公开'* 的方法有很大的缺陷,但WORD却做得很好,因此才尝试解决这个问题。
'* 过程比我预期的要曲折的多,主要是VBA实在是一种很受限制的语言。
'* 不过好在有Google和Olldbg,难题也仅仅是如何找到绕过限制的途径,'* 终于在5个小时内搞定了一切~'* 时间比我预计的长了很多,因为我实在是不了解VBA,也不很熟悉OLE:"('* 不过好在一切都解决了~~终于从VBA小白成长了一些。
'* 其实VBA也是很强大的~'*'* Theory:废话了好多还是说说原理吧,虽然不是每个人都很关心~'* WORD的拼音向导能够将汉字转成拼音全是倚仗微软拼音的帮助,'* 微软拼音2.0以上版本都提供了汉字到拼音的转换功能。
'* 微软拼音MSIME.China类中的IFELanguage接口具体实现了转换功能'* 不过MSIME.China中没有提供IDispatch接口,VBA的CreateObject 不支持'* 调用这样的类,因此我们只好手工调用。
CoCreateInstance可以创建类'* 并获取IFELanguage接口,但我们无法直接调用,因为VBA不知道如何调用'* IFELanguage接口的Method。
C#真正完美的汉字转拼音

C#真正完美的汉字转拼⾳⽹上有很多说⾃⼰整理的汉字转拼⾳是完美的,但使⽤后才发现都是半吊的瓶⼦,问题多多。
常见的⽣僻字,或多⾳字识别,转换后简直让⼈感觉可怕。
主流的转换有三种:hash匹配,Npinyin,微软PinYinConverter。
但单⽤这三个,都没法做到完美,为什么没⼈考虑融合呢?我的⽅案:Npinyin+微软PinYinConverter(⾸选Npinyin)微软PinYinConverter为什么:微软PinYinConverter很强⼤,但在多⾳字⾯前,犯了传统的错误,按拼⾳字母排序。
如【强】微软居然优先【jiang】⽽不是】【qiang】所以不能优选 PinYinConverter。
Npinyin很⼈性,很不错的第三⽅库,在传统多⾳字前优先使⽤率较⾼的,但在⽣僻字⾯前有点⽆法转换。
(GetInitials(strChinese) 有Bug 如【洺】⽆法识别,但GetPinyin可以正常转换。
)总结:优先Npinyin 翻译失败的使⽤微软PinYinConverter。
⽬测完美。
上代码:public class PingYinHelper{private static Encoding gb2312 = Encoding.GetEncoding("GB2312");///<summary>///汉字转全拼///</summary>///<param name="strChinese"></param>///<returns></returns>public static string ConvertToAllSpell(string strChinese){try{if (strChinese.Length != 0){StringBuilder fullSpell = new StringBuilder();for (int i = 0; i < strChinese.Length; i++){var chr = strChinese[i];fullSpell.Append(GetSpell(chr));}return fullSpell.ToString().ToUpper();}}catch (Exception e){Console.WriteLine("全拼转化出错!" + e.Message);}return string.Empty;}///<summary>///汉字转⾸字母///</summary>///<param name="strChinese"></param>///<returns></returns>public static string GetFirstSpell(string strChinese){//NPinyin.Pinyin.GetInitials(strChinese) 有Bug 洺⽆法识别//return NPinyin.Pinyin.GetInitials(strChinese);try{if (strChinese.Length != 0){StringBuilder fullSpell = new StringBuilder();for (int i = 0; i < strChinese.Length; i++){var chr = strChinese[i];fullSpell.Append(GetSpell(chr)[0]);}return fullSpell.ToString().ToUpper();}}catch (Exception e){Console.WriteLine("⾸字母转化出错!" + e.Message);}return string.Empty;}private static string GetSpell(char chr){var coverchr = NPinyin.Pinyin.GetPinyin(chr);bool isChineses = ChineseChar.IsValidChar(coverchr[0]);if (isChineses){ChineseChar chineseChar = new ChineseChar(coverchr[0]);foreach (string value in chineseChar.Pinyins){if (!string.IsNullOrEmpty(value)){return value.Remove(value.Length - 1, 1);}}}return coverchr;}}抽了⼏个常见错字和姓名测试如下:[TestMethod]public void PingyinTest(){Dictionary<string, Tuple<string, string>> dict = newDictionary<string, Tuple<string, string>>() {{"梅钰", new Tuple<string,string>( "meiyu","MY")},{"张洺", new Tuple<string,string>( "zhangming","ZM")},{"王玥", new Tuple<string,string>( "wangyue","WY")},{"王思琪", new Tuple<string,string>( "wangsiqi","WSQ")},{"董云强", new Tuple<string,string>( "dongyunqiang","DYQ")},{"宋红培", new Tuple<string,string>( "songhongpei","SHP")},{"⽯磊", new Tuple<string,string>( "shilei","SL")},};foreach (var keyval in dict){var name = keyval.Key;var spell1 = keyval.Value.Item1;var spell2 = keyval.Value.Item2;var val = ChineseSpell.ConvertToAllSpell(name).TrimAll();val = monLib.PingYinHelper.ConvertToAllSpell(name).TrimAll().ToLower();Assert.IsTrue(val == spell1, "转换错误");val = monLib.ChineseSpell.GetFirstSpell(name).TrimAll(); val = monLib.PingYinHelper.GetFirstSpell(name).TrimAll(); Assert.IsTrue(val == spell2, "转换错误");}}。
中文转拼音函数公式

中文转拼音函数公式1.将待转换的中文字符串处理成字符列表。
2.初始化一个空的拼音列表,用于存储拼音音节。
3.开始遍历字符列表,对每个字符进行处理。
4.判断当前字符是否为汉字。
-如果是汉字,则进行以下步骤:a.对汉字进行拼音转换,得到对应的拼音列表。
b.将拼音列表添加到总拼音列表中。
-如果不是汉字,则将当前字符直接添加到总拼音列表中。
5.将总拼音列表中的音节连接成一个字符串,并返回结果。
这个函数公式的实现可以参考以下示例代码:```pythonimport pypinyindef hanzi_to_pinyin(text):#将待转换的中文字符串处理成字符列表chars = list(text)#初始化一个空的拼音列表pinyin_list = []#遍历字符列表,对每个字符进行处理for char in chars:#判断当前字符是否为汉字if '\u4e00' <= char <= '\u9fa5': # 判断一个字符是否是中文汉字#对汉字进行拼音转换,得到对应的拼音列表pinyin = pypinyin.pinyin(char, style=pypinyin.NORMAL)#将拼音列表添加到总拼音列表中pinyin_list.extend([x[0] for x in pinyin])else:#如果不是汉字,则将当前字符直接添加到总拼音列表中pinyin_list.append(char)#将总拼音列表中的音节连接成一个字符串,并返回结果return ''.join(pinyin_list)text = '中文转拼音函数公式'pinyin = hanzi_to_pinyin(text)print(pinyin) # 输出结果:zhōng wén zhuǎn pīn yīn hán shù gōng shì```这个函数利用了第三方库`pypinyin`来实现中文转拼音的功能。
中文转拼音的函数

中文转拼音的函数一、概述中文转拼音是指将汉字转换为对应的拼音(英文字母),以方便国际交流和计算机处理。
在日常生活中,我们经常会使用中文拼音来搜索、输入或标注汉字,因此中文转拼音的函数非常有用,可以帮助我们快速、准确地进行这些操作。
本文将介绍如何编写一个功能完备的中文转拼音的函数,以满足各种实际需求。
二、拼音系统拼音系统是指将汉字按照一定的规则转换为对应的拼音的方法和标准。
目前常用的拼音系统有汉语拼音、注音符号、粤语拼音等。
在本文中,我们将以汉语拼音为基础,讲解如何实现中文转拼音的函数。
三、常见的中文转拼音方法中文转拼音的方法有很多种,例如:1.首字母缩写法:根据汉字的拼音首字母进行缩写,如”中国”可以转换为”ZG”;2.全拼法:将每个汉字根据发音转换为拼音字母,如”中国”可以转换为”zhong guo”;3.多音字处理:在转换过程中,对于拼音有多个读音的汉字,需要根据上下文或词组进行正确的匹配,如”重庆”的读音可以是”chong qing”或”zhong qing”;4.音调标记法:在拼音的基础上,使用数字或符号表示声调,如”zhōng guó”表示”中国”的拼音。
下面我们将以全拼法为例,介绍如何编写一个函数来实现中文转拼音。
四、Python实现中文转拼音的函数1. 安装拼音库为了方便地实现中文转拼音的功能,我们可以使用Python的拼音库,例如pypinyin库。
可以使用以下命令来安装该库:pip install pypinyin2. 导入拼音库安装完成后,我们需要在Python代码中导入该库,并进行初始化操作:import pypinyinpypinyin.load_phrases_dict()3. 编写转换函数接下来,我们可以编写一个函数来实现中文转拼音的功能:def chinese_to_pinyin(chinese_str):pinyin_list = pypinyin.pinyin(chinese_str, style=pypinyin.NORMAL) pinyin_str_list = []for pinyin in pinyin_list:pinyin_str_list.append(pinyin[0])return ' '.join(pinyin_str_list)4. 使用示例我们可以使用以下代码来测试刚刚编写的中文转拼音函数:chinese_str = "中国"pinyin = chinese_to_pinyin(chinese_str)print(pinyin) # 输出:"zhong guo"五、进阶功能扩展1. 多音字处理在实际应用中,由于汉字存在多音字的情况,因此需要对多音字进行正确的匹配。
原创oracle数据库应用中实现汉字“同音”查询数据库教程-电脑资料

原创oracle数据库应用中实现汉字“同音”查询数据库教程-电脑资料oracle|汉字|数据|数据库|原创要实现“同音”查询当然要先得到汉字的汉语拼音了,在网上随处可以找到ASP的汉字转拼音的代码,如以下代码:<% Set d = CreateObject("Scripting.Dictionary") d.add "a",-20319 d.add "ai",-20317 d.add "an",-20304 d.add "ang",-20295 d.add "ao",-20292 d.add "ba",-20283 d.add "bai",-20265 d.add "ban",-20257 d.add "bang",-20242 d.add "bao",-20230 d.add "bei",-20051 d.add "ben",-20036 d.add "beng",-20032 d.add "bi",-20026 d.add "bian",-20002 d.add "biao",-19990 d.add "bie",-19986 d.add "bin",-19982 d.add "bing",-19976 d.add "bo",-19805 d.add "bu",-19784 d.add "ca",-19775 d.add "cai",-19774 d.add "can",-19763 d.add "cang",-19756 d.add "cao",-19751 d.add "ce",-19746 d.add "ceng",-19741 d.add "cha",-19739 d.add "chai",-19728 d.add "chan",-19725 d.add "chang",-19715 d.add "chao",-19540 d.add "che",-19531 d.add "chen",-19525 d.add "cheng",-19515 d.add "chi",-19500 d.add "chong",-19484 d.add "chou",-19479 d.add "chu",-19467 d.add "chuai",-19289 d.add "chuan",-19288 d.add "chuang",-19281 d.add "chui",-19275 d.add "chun",-19270 d.add "chuo",-19263 d.add "ci",-19261 d.add "cong",-19249 d.add "cou",-19243 d.add "cu",-19242 d.add "cuan",-19238 d.add "cui",-19235 d.add "cun",-19227 d.add "cuo",-19224 d.add "da",-19218 d.add "dai",-19212 d.add "dan",-19038 d.add "dang",-19023 d.add "dao",-19018 d.add "de",-19006 d.add "deng",-19003 d.add "di",-18996 d.add "dian",-18977 d.add "diao",-18961 d.add "die",-18952 d.add "ding",-18783 d.add"diu",-18774 d.add "dong",-18773 d.add "dou",-18763 d.add "du",-18756 d.add "duan",-18741 d.add "dui",-18735 d.add "dun",-18731 d.add "duo",-18722 d.add "e",-18710 d.add "en",-18697 d.add "er",-18696 d.add "fa",-18526 d.add "fan",-18518 d.add "fang",-18501 d.add "fei",-18490 d.add "fen",-18478 d.add "feng",-18463 d.add "fo",-18448 d.add "fou",-18447 d.add "fu",-18446 d.add "ga",-18239 d.add "gai",-18237 d.add "gan",-18231 d.add "gang",-18220 d.add "gao",-18211 d.add "ge",-18201 d.add "gei",-18184 d.add "gen",-18183 d.add "geng",-18181 d.add "gong",-18012 d.add "gou",-17997 d.add "gu",-17988 d.add "gua",-17970 d.add "guai",-17964 d.add "guan",-17961 d.add "guang",-17950 d.add "gui",-17947 d.add "gun",-17931 d.add "guo",-17928 d.add "ha",-17922 d.add "hai",-17759 d.add "han",-17752 d.add "hang",-17733 d.add "hao",-17730 d.add "he",-17721 d.add "hei",-17703 d.add "hen",-17701 d.add "heng",-17697 d.add "hong",-17692 d.add "hou",-17683 d.add "hu",-17676 d.add "hua",-17496 d.add "huai",-17487 d.add "huan",-17482 d.add "huang",-17468 d.add "hui",-17454 d.add "hun",-17433 d.add "huo",-17427 d.add "ji",-17417 d.add "jia",-17202 d.add "jian",-17185 d.add "jiang",-16983 d.add "jiao",-16970 d.add "jie",-16942 d.add "jin",-16915 d.add "jing",-16733 d.add "jiong",-16708 d.add "jiu",-16706 d.add "ju",-16689 d.add "juan",-16664 d.add "jue",-16657 d.add "jun",-16647 d.add "ka",-16474 d.add "kai",-16470 d.add "kan",-16465 d.add "kang",-16459 d.add "kao",-16452 d.add "ke",-16448 d.add "ken",-16433 d.add "keng",-16429 d.add "kong",-16427 d.add "kou",-16423 d.add "ku",-16419 d.add "kua",-16412 d.add "kuai",-16407 d.add "kuan",-16403 d.add"kuang",-16401 d.add "kui",-16393 d.add "kun",-16220 d.add "kuo",-16216 d.add "la",-16212 d.add "lai",-16205 d.add "lan",-16202 d.add "lang",-16187 d.add "lao",-16180 d.add "le",-16171 d.add "lei",-16169 d.add "leng",-16158 d.add "li",-16155 d.add "lia",-15959 d.add "lian",-15958 d.add "liang",-15944 d.add "liao",-15933 d.add "lie",-15920 d.add "lin",-15915 d.add "ling",-15903 d.add "liu",-15889 d.add "long",-15878 d.add "lou",-15707 d.add "lu",-15701 d.add "lv",-15681 d.add "luan",-15667 d.add "lue",-15661 d.add "lun",-15659 d.add "luo",-15652 d.add "ma",-15640 d.add "mai",-15631 d.add "man",-15625 d.add "mang",-15454 d.add "mao",-15448 d.add "me",-15436 d.add "mei",-15435 d.add "men",-15419 d.add "meng",-15416 d.add "mi",-15408 d.add "mian",-15394 d.add "miao",-15385 d.add "mie",-15377 d.add "min",-15375 d.add "ming",-15369 d.add "miu",-15363 d.add "mo",-15362 d.add "mou",-15183 d.add "mu",-15180 d.add "na",-15165 d.add "nai",-15158 d.add "nan",-15153 d.add "nang",-15150 d.add "nao",-15149 d.add "ne",-15144 d.add "nei",-15143 d.add "nen",-15141 d.add "neng",-15140 d.add "ni",-15139 d.add "nian",-15128 d.add "niang",-15121 d.add "niao",-15119 d.add "nie",-15117 d.add "nin",-15110 d.add "ning",-15109 d.add "niu",-14941 d.add "nong",-14937 d.add "nu",-14933 d.add "nv",-14930 d.add "nuan",-14929 d.add "nue",-14928 d.add "nuo",-14926 d.add "o",-14922 d.add "ou",-14921 d.add "pa",-14914 d.add "pai",-14908 d.add "pan",-14902 d.add "pang",-14894 d.add "pao",-14889 d.add "pei",-14882 d.add "pen",-14873 d.add "peng",-14871 d.add "pi",-14857 d.add "pian",-14678 d.add "piao",-14674 d.add "pie",-14670 d.add "pin",-14668 d.add"ping",-14663 d.add "po",-14654 d.add "pu",-14645 d.add "qi",-14630 d.add "qia",-14594 d.add "qian",-14429 d.add "qiang",-14407 d.add "qiao",-14399 d.add "qie",-14384 d.add "qin",-14379 d.add "qing",-14368 d.add "qiong",-14355 d.add "qiu",-14353 d.add "qu",-14345 d.add "quan",-14170 d.add "que",-14159 d.add "qun",-14151 d.add "ran",-14149 d.add "rang",-14145 d.add "rao",-14140 d.add "re",-14137 d.add "ren",-14135 d.add "reng",-14125 d.add "ri",-14123 d.add "rong",-14122 d.add "rou",-14112 d.add "ru",-14109 d.add "ruan",-14099 d.add "rui",-14097 d.add "run",-14094 d.add "ruo",-14092 d.add "sa",-14090 d.add "sai",-14087 d.add "san",-14083 d.add "sang",-13917 d.add "sao",-13914 d.add "se",-13910 d.add "sen",-13907 d.add "seng",-13906 d.add "sha",-13905 d.add "shai",-13896 d.add "shan",-13894 d.add "shang",-13878 d.add "shao",-13870 d.add "she",-13859 d.add "shen",-13847 d.add "sheng",-13831 d.add "shi",-13658 d.add "shou",-13611 d.add "shu",-13601 d.add "shua",-13406 d.add "shuai",-13404 d.add "shuan",-13400 d.add "shuang",-13398 d.add "shui",-13395 d.add "shun",-13391 d.add "shuo",-13387 d.add "si",-13383 d.add "song",-13367 d.add "sou",-13359 d.add "su",-13356 d.add "suan",-13343 d.add "sui",-13340 d.add "sun",-13329 d.add "suo",-13326 d.add "ta",-13318 d.add "tai",-13147 d.add "tan",-13138 d.add "tang",-13120 d.add "tao",-13107 d.add "te",-13096 d.add "teng",-13095 d.add "ti",-13091 d.add "tian",-13076 d.add "tiao",-13068 d.add "tie",-13063 d.add "ting",-13060 d.add "tong",-12888 d.add "tou",-12875 d.add "tu",-12871 d.add "tuan",-12860 d.add "tui",-12858 d.add "tun",-12852 d.add "tuo",-12849 d.add "wa",-12838 d.add "wai",-12831 d.add"wan",-12829 d.add "wang",-12812 d.add "wei",-12802 d.add "wen",-12607 d.add "weng",-12597 d.add "wo",-12594 d.add "wu",-12585 d.add "xi",-12556 d.add "xia",-12359 d.add "xian",-12346 d.add "xiang",-12320 d.add "xiao",-12300 d.add "xie",-12120 d.add "xin",-12099 d.add "xing",-12089 d.add "xiong",-12074 d.add "xiu",-12067 d.add "xu",-12058 d.add "xuan",-12039 d.add "xue",-11867 d.add "xun",-11861 d.add "ya",-11847 d.add "yan",-11831 d.add "yang",-11798 d.add "yao",-11781 d.add "ye",-11604 d.add "yi",-11589 d.add "yin",-11536 d.add "ying",-11358 d.add "yo",-11340 d.add "yong",-11339 d.add "you",-11324 d.add "yu",-11303 d.add "yuan",-11097 d.add "yue",-11077 d.add "yun",-11067 d.add "za",-11055 d.add "zai",-11052 d.add "zan",-11045 d.add "zang",-11041 d.add "zao",-11038 d.add "ze",-11024 d.add "zei",-11020 d.add "zen",-11019 d.add "zeng",-11018 d.add "zha",-11014 d.add "zhai",-10838 d.add "zhan",-10832 d.add "zhang",-10815 d.add "zhao",-10800 d.add "zhe",-10790 d.add "zhen",-10780 d.add "zheng",-10764 d.add "zhi",-10587 d.add "zhong",-10544 d.add "zhou",-10533 d.add "zhu",-10519 d.add "zhua",-10331 d.add "zhuai",-10329 d.add "zhuan",-10328 d.add "zhuang",-10322 d.add "zhui",-10315 d.add "zhun",-10309 d.add "zhuo",-10307 d.add "zi",-10296 d.add "zong",-10281 d.add "zou",-10274 d.add "zu",-10270 d.add "zuan",-10262 d.add "zui",-10260 d.add "zun",-10256 d.add "zuo",-10254 function g(num) if num>0 and num<160 then g=chr(num) else if num<-20319 or num>-10247 then g="" else a=d.Items b=d.keys for i=d.count-1 to 0 step -1 if a(i)<=num then exit for next g=b(i) end if end if end function function c(str) c="" for i=1 tolen(str) c=c&g(asc(mid(str,i,1))) next endfunction response.write c(request("hz")) %> 请在此处输入中以上代码的原理十分简单,这里我不多说了,下面我们把上面的码表导入oracle表中,不过要注意一下,oracle中内置的ASCII()函数于VB中的ASC()函数的返回值范围不同,我们需要加上65536得出的才是oracle中汉字的ascii码,如:VB中ASC("啊")=-20319,在oracle中ASCII("啊")=-20319+65536=45217,。
oracle数据库根据汉字生成拼音简码

oracle数据库根据汉字生成拼音简码create or replace function f_name_to_pinyin(as_inputstring varchar2, al_len number) return varchar2 isi number;ls_ch varchar2(1000);ls_returnstr varchar2(1000);beginif as_inputstring is null thenreturn null;end if;ls_returnstr := null;i := 1;loopls_ch := substr(as_inputstring, i, 1);if ascii(ls_ch) < 128 thenls_returnstr := ls_returnstr || upper(ls_ch);elseif ls_ch in ('铵', '庵') thenls_returnstr := ls_returnstr || 'A';elsif ls_ch in ('蟾') thenls_returnstr := ls_returnstr || 'C';elsif ls_ch in ('鑫', '酰', '馨', '逍') thenls_returnstr := ls_returnstr || 'X';elsif ls_ch in ('绮', '嗪', '祛', '琪', '倩', '羟', '芩', '杞', '衢') thenls_returnstr := ls_returnstr || 'Q';elsif ls_ch in ('膦', '蓼', '榄', '蛎', '蒺', '蔹', '啉', '莨', '苓', '苈', '楝') thenls_returnstr := ls_returnstr || 'L';elsif ls_ch in ('癀', '琥', '荟', '藿', '茴', '槲', '斛', '蛤', '昊') thenls_returnstr := ls_returnstr || 'H';elsif ls_ch in ('苄', '铋', '檗', '孢') thenls_returnstr := ls_returnstr || 'B';elsif ls_ch in ('啶', '黛', '酊', '椴', '菪', '哚') thenls_returnstr := ls_returnstr || 'D';elsif ls_ch = '噁' thenls_returnstr := ls_returnstr || 'E';elsif ls_ch in ('埚', '枸', '坩', '苷', '橄', '呱', '酐', '甙', '胱', '钴', '蚣') thenls_returnstr := ls_returnstr || 'G';elsif ls_ch in ('皲', '芨', '蒺', '戟') thenls_returnstr := ls_returnstr || 'J';elsif ls_ch in ('孚', '茯') thenls_returnstr := ls_returnstr || 'F';elsif ls_ch in ('蔻', '匮') thenls_returnstr := ls_returnstr || 'K';elsif ls_ch in ('蟆', '莓', '咪', '朦', '沐', '嘧', '眸') thenls_returnstr := ls_returnstr || 'M';elsif ls_ch in ('脲', '萘', '蛲', '咛') thenls_returnstr := ls_returnstr || 'N';elsif ls_ch in ('脘', '薇', '蜈', '菀') thenls_returnstr := ls_returnstr || 'W';elsif ls_ch in ('溴', '昔', '蛸') thenls_returnstr := ls_returnstr || 'X';elsif ls_ch in ('龈', '橼', '瘀', '翳', '鸦', '吲', '薏', '苡', '萸', '榈') then ls_returnstr := ls_returnstr || 'Y';elsif ls_ch in ('佗', '肽', '葶') thenls_returnstr := ls_returnstr || 'T';elsif ls_ch = '髯' thenls_returnstr := ls_returnstr || 'R';elsif ls_ch = '参' and substr(as_inputstring, i + 1, 1) in ('数','加','考','观') thenls_returnstr := ls_returnstr || 'C';elsif ls_ch in ('参', '噻', '麝', '椹', '熵') thenls_returnstr := ls_returnstr || 'S';elsif ls_ch in ('哌', '吡', '嘌', '珀', '枇', '杷', '螵') thenls_returnstr := ls_returnstr || 'P';elsifls_ch in ('唑') thenls_returnstr := ls_returnstr || 'Z';elsif ls_ch = '调' and substr(as_inputstring, i + 1, 1) = '节' then ls_returnstr := ls_returnstr || 'T';elsif ls_ch = '弹' and substr(as_inputstring, i + 1, 1) = '簧' then ls_returnstr := ls_returnstr || 'T';elsif ls_ch = '重' and substr(as_inputstring, i + 1, 1) = '庆' then ls_returnstr := ls_returnstr || 'C';elsif ls_ch = '会' and substr(as_inputstring, i + 1, 1) = '计' then ls_returnstr := ls_returnstr || 'K';elsif ls_ch = '调' and substr(as_inputstring, i + 1, 1) = '整' then ls_returnstr := ls_returnstr || 'T';elsif ls_ch = '长' and substr(as_inputstring, i - 1, 1) in ('厂', '科', '所', '组', '站', '班', '事') thenls_returnstr := ls_returnstr || 'Z';elsif ls_ch = '行' and substr(as_inputstring, i - 1, 1) in ('银') thenls_returnstr := ls_returnstr || 'H';elsif ls_ch >= '匝' thenls_returnstr := ls_returnstr || 'Z';elsif ls_ch >= '丫' thenls_returnstr := ls_returnstr || 'Y';ls_returnstr := ls_returnstr || 'X'; elsif ls_ch >= '哇' thenls_returnstr := ls_returnstr || 'W'; elsif ls_ch >= '他' thenls_returnstr := ls_returnstr || 'T'; elsif ls_ch >= '撒' thenls_returnstr := ls_returnstr || 'S'; elsif ls_ch >= '然' thenls_returnstr := ls_returnstr || 'R'; elsif ls_ch >= '期' thenls_returnstr := ls_returnstr || 'Q'; elsif ls_ch >= '趴' thenls_returnstr := ls_returnstr || 'P'; elsif ls_ch >= '哦' thenls_returnstr := ls_returnstr || 'O'; elsif ls_ch >= '拿' thenls_returnstr := ls_returnstr || 'N'; elsif ls_ch >= '妈' thenls_returnstr := ls_returnstr || 'M'; elsif ls_ch >= '廓' thenls_returnstr := ls_returnstr || 'L'; elsif ls_ch >= '咖' thenls_returnstr := ls_returnstr || 'K'; elsif ls_ch >= '击' thenls_returnstr := ls_returnstr || 'J'; elsif ls_ch >= '哈' thenls_returnstr := ls_returnstr || 'H'; elsif ls_ch >= '嘎' thenls_returnstr := ls_returnstr || 'G';ls_returnstr := ls_returnstr || 'F';elsif ls_ch >= '额' thenls_returnstr := ls_returnstr || 'E';elsif ls_ch >= '搭' thenls_returnstr := ls_returnstr || 'D';elsif ls_ch >= '擦' thenls_returnstr := ls_returnstr || 'C';elsif ls_ch >= '八' thenls_returnstr := ls_returnstr || 'B';elsif ls_ch >= '阿' thenls_returnstr := ls_returnstr || 'A';end if;end if;i := i + 1;if i > length(as_inputstring) thenexit;end if;end loop;if nvl(al_len, 0) > 0 thenls_returnstr := substr(ls_returnstr, 1, al_len );end if;return ls_returnstr;end f_name_to_pinyin;。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
第一种方法:(首字母/全拼)create or replace type spell_code as object(spell varchar2(10),code number); create or replace type t_spellcode is table of spell_code;--返回拼音与代码的对应关系create or replace function f_getSpellcode return t_spellcode PipelinedisBeginPIPE Row(spell_code('a', -20319));PIPE Row(spell_code('ai', -20317));PIPE Row(spell_code('an', -20304));PIPE Row(spell_code('ang', -20295));PIPE Row(spell_code('ao', -20292));PIPE Row(spell_code('ba', -20283));PIPE Row(spell_code('bai', -20265));PIPE Row(spell_code('ban', -20257));PIPE Row(spell_code('bang', -20242));PIPE Row(spell_code('bao', -20230));PIPE Row(spell_code('bei', -20051));PIPE Row(spell_code('ben', -20036));PIPE Row(spell_code('beng', -20032));PIPE Row(spell_code('bi', -20026));PIPE Row(spell_code('bian', -20002));PIPE Row(spell_code('biao', -19990));PIPE Row(spell_code('bie', -19986));PIPE Row(spell_code('bin', -19982));PIPE Row(spell_code('bing', -19976));PIPE Row(spell_code('bo', -19805));PIPE Row(spell_code('bu', -19784));PIPE Row(spell_code('ca', -19775));PIPE Row(spell_code('cai', -19774));PIPE Row(spell_code('can', -19763));PIPE Row(spell_code('cang', -19756));PIPE Row(spell_code('cao', -19751));PIPE Row(spell_code('ce', -19746));PIPE Row(spell_code('ceng', -19741));PIPE Row(spell_code('cha', -19739));PIPE Row(spell_code('chan', -19725)); PIPE Row(spell_code('chang', -19715)); PIPE Row(spell_code('chao', -19540)); PIPE Row(spell_code('che', -19531)); PIPE Row(spell_code('chen', -19525)); PIPE Row(spell_code('cheng', -19515)); PIPE Row(spell_code('chi', -19500)); PIPE Row(spell_code('chong', -19484)); PIPE Row(spell_code('chou', -19479)); PIPE Row(spell_code('chu', -19467)); PIPE Row(spell_code('chuai', -19289)); PIPE Row(spell_code('chuan', -19288)); PIPE Row(spell_code('chuang', -19281)); PIPE Row(spell_code('chui', -19275)); PIPE Row(spell_code('chun', -19270)); PIPE Row(spell_code('chuo', -19263)); PIPE Row(spell_code('ci', -19261)); PIPE Row(spell_code('cong', -19249)); PIPE Row(spell_code('cou', -19243)); PIPE Row(spell_code('cu', -19242)); PIPE Row(spell_code('cuan', -19238)); PIPE Row(spell_code('cui', -19235)); PIPE Row(spell_code('cun', -19227)); PIPE Row(spell_code('cuo', -19224)); PIPE Row(spell_code('da', -19218)); PIPE Row(spell_code('dai', -19212)); PIPE Row(spell_code('dan', -19038)); PIPE Row(spell_code('dang', -19023)); PIPE Row(spell_code('dao', -19018)); PIPE Row(spell_code('de', -19006)); PIPE Row(spell_code('deng', -19003)); PIPE Row(spell_code('di', -18996)); PIPE Row(spell_code('dian', -18977)); PIPE Row(spell_code('diao', -18961)); PIPE Row(spell_code('die', -18952)); PIPE Row(spell_code('ding', -18783)); PIPE Row(spell_code('diu', -18774));PIPE Row(spell_code('dou', -18763)); PIPE Row(spell_code('du', -18756)); PIPE Row(spell_code('duan', -18741)); PIPE Row(spell_code('dui', -18735)); PIPE Row(spell_code('dun', -18731)); PIPE Row(spell_code('duo', -18722)); PIPE Row(spell_code('e', -18710)); PIPE Row(spell_code('en', -18697)); PIPE Row(spell_code('er', -18696)); PIPE Row(spell_code('fa', -18526)); PIPE Row(spell_code('fan', -18518)); PIPE Row(spell_code('fang', -18501)); PIPE Row(spell_code('fei', -18490)); PIPE Row(spell_code('fen', -18478)); PIPE Row(spell_code('feng', -18463)); PIPE Row(spell_code('fo', -18448)); PIPE Row(spell_code('fou', -18447)); PIPE Row(spell_code('fu', -18446)); PIPE Row(spell_code('ga', -18239)); PIPE Row(spell_code('gai', -18237)); PIPE Row(spell_code('gan', -18231)); PIPE Row(spell_code('gang', -18220)); PIPE Row(spell_code('gao', -18211)); PIPE Row(spell_code('ge', -18201)); PIPE Row(spell_code('gei', -18184)); PIPE Row(spell_code('gen', -18183)); PIPE Row(spell_code('geng', -18181)); PIPE Row(spell_code('gong', -18012)); PIPE Row(spell_code('gou', -17997)); PIPE Row(spell_code('gu', -17988)); PIPE Row(spell_code('gua', -17970)); PIPE Row(spell_code('guai', -17964)); PIPE Row(spell_code('guan', -17961)); PIPE Row(spell_code('guang', -17950)); PIPE Row(spell_code('gui', -17947)); PIPE Row(spell_code('gun', -17931)); PIPE Row(spell_code('guo', -17928));PIPE Row(spell_code('hai', -17759)); PIPE Row(spell_code('han', -17752)); PIPE Row(spell_code('hang', -17733)); PIPE Row(spell_code('hao', -17730)); PIPE Row(spell_code('he', -17721)); PIPE Row(spell_code('hei', -17703)); PIPE Row(spell_code('hen', -17701)); PIPE Row(spell_code('heng', -17697)); PIPE Row(spell_code('hong', -17692)); PIPE Row(spell_code('hou', -17683)); PIPE Row(spell_code('hu', -17676)); PIPE Row(spell_code('hua', -17496)); PIPE Row(spell_code('huai', -17487)); PIPE Row(spell_code('huan', -17482)); PIPE Row(spell_code('huang', -17468)); PIPE Row(spell_code('hui', -17454)); PIPE Row(spell_code('hun', -17433)); PIPE Row(spell_code('huo', -17427)); PIPE Row(spell_code('ji', -17417)); PIPE Row(spell_code('jia', -17202)); PIPE Row(spell_code('jian', -17185)); PIPE Row(spell_code('jiang', -16983)); PIPE Row(spell_code('jiao', -16970)); PIPE Row(spell_code('jie', -16942)); PIPE Row(spell_code('jin', -16915)); PIPE Row(spell_code('jing', -16733)); PIPE Row(spell_code('jiong', -16708)); PIPE Row(spell_code('jiu', -16706)); PIPE Row(spell_code('ju', -16689)); PIPE Row(spell_code('juan', -16664)); PIPE Row(spell_code('jue', -16657)); PIPE Row(spell_code('jun', -16647)); PIPE Row(spell_code('ka', -16474)); PIPE Row(spell_code('kai', -16470)); PIPE Row(spell_code('kan', -16465)); PIPE Row(spell_code('kang', -16459)); PIPE Row(spell_code('kao', -16452));PIPE Row(spell_code('ken', -16433)); PIPE Row(spell_code('keng', -16429)); PIPE Row(spell_code('kong', -16427)); PIPE Row(spell_code('kou', -16423)); PIPE Row(spell_code('ku', -16419)); PIPE Row(spell_code('kua', -16412)); PIPE Row(spell_code('kuai', -16407)); PIPE Row(spell_code('kuan', -16403)); PIPE Row(spell_code('kuang', -16401)); PIPE Row(spell_code('kui', -16393)); PIPE Row(spell_code('kun', -16220)); PIPE Row(spell_code('kuo', -16216)); PIPE Row(spell_code('la', -16212)); PIPE Row(spell_code('lai', -16205)); PIPE Row(spell_code('lan', -16202)); PIPE Row(spell_code('lang', -16187)); PIPE Row(spell_code('lao', -16180)); PIPE Row(spell_code('le', -16171)); PIPE Row(spell_code('lei', -16169)); PIPE Row(spell_code('leng', -16158)); PIPE Row(spell_code('li', -16155)); PIPE Row(spell_code('lia', -15959)); PIPE Row(spell_code('lian', -15958)); PIPE Row(spell_code('liang', -15944)); PIPE Row(spell_code('liao', -15933)); PIPE Row(spell_code('lie', -15920)); PIPE Row(spell_code('lin', -15915)); PIPE Row(spell_code('ling', -15903)); PIPE Row(spell_code('liu', -15889)); PIPE Row(spell_code('long', -15878)); PIPE Row(spell_code('lou', -15707)); PIPE Row(spell_code('lu', -15701)); PIPE Row(spell_code('lv', -15681)); PIPE Row(spell_code('luan', -15667)); PIPE Row(spell_code('lue', -15661)); PIPE Row(spell_code('lun', -15659)); PIPE Row(spell_code('luo', -15652));PIPE Row(spell_code('mai', -15631)); PIPE Row(spell_code('man', -15625)); PIPE Row(spell_code('mang', -15454)); PIPE Row(spell_code('mao', -15448)); PIPE Row(spell_code('me', -15436)); PIPE Row(spell_code('mei', -15435)); PIPE Row(spell_code('men', -15419)); PIPE Row(spell_code('meng', -15416)); PIPE Row(spell_code('mi', -15408)); PIPE Row(spell_code('mian', -15394)); PIPE Row(spell_code('miao', -15385)); PIPE Row(spell_code('mie', -15377)); PIPE Row(spell_code('min', -15375)); PIPE Row(spell_code('ming', -15369)); PIPE Row(spell_code('miu', -15363)); PIPE Row(spell_code('mo', -15362)); PIPE Row(spell_code('mou', -15183)); PIPE Row(spell_code('mu', -15180)); PIPE Row(spell_code('na', -15165)); PIPE Row(spell_code('nai', -15158)); PIPE Row(spell_code('nan', -15153)); PIPE Row(spell_code('nang', -15150)); PIPE Row(spell_code('nao', -15149)); PIPE Row(spell_code('ne', -15144)); PIPE Row(spell_code('nei', -15143)); PIPE Row(spell_code('nen', -15141)); PIPE Row(spell_code('neng', -15140)); PIPE Row(spell_code('ni', -15139)); PIPE Row(spell_code('nian', -15128)); PIPE Row(spell_code('niang', -15121)); PIPE Row(spell_code('niao', -15119)); PIPE Row(spell_code('nie', -15117)); PIPE Row(spell_code('nin', -15110)); PIPE Row(spell_code('ning', -15109)); PIPE Row(spell_code('niu', -14941)); PIPE Row(spell_code('nong', -14937)); PIPE Row(spell_code('nu', -14933));PIPE Row(spell_code('nuan', -14929)); PIPE Row(spell_code('nue', -14928)); PIPE Row(spell_code('nuo', -14926)); PIPE Row(spell_code('o', -14922)); PIPE Row(spell_code('ou', -14921)); PIPE Row(spell_code('pa', -14914)); PIPE Row(spell_code('pai', -14908)); PIPE Row(spell_code('pan', -14902)); PIPE Row(spell_code('pang', -14894)); PIPE Row(spell_code('pao', -14889)); PIPE Row(spell_code('pei', -14882)); PIPE Row(spell_code('pen', -14873)); PIPE Row(spell_code('peng', -14871)); PIPE Row(spell_code('pi', -14857)); PIPE Row(spell_code('pian', -14678)); PIPE Row(spell_code('piao', -14674)); PIPE Row(spell_code('pie', -14670)); PIPE Row(spell_code('pin', -14668)); PIPE Row(spell_code('ping', -14663)); PIPE Row(spell_code('po', -14654)); PIPE Row(spell_code('pu', -14645)); PIPE Row(spell_code('qi', -14630)); PIPE Row(spell_code('qia', -14594)); PIPE Row(spell_code('qian', -14429)); PIPE Row(spell_code('qiang', -14407)); PIPE Row(spell_code('qiao', -14399)); PIPE Row(spell_code('qie', -14384)); PIPE Row(spell_code('qin', -14379)); PIPE Row(spell_code('qing', -14368)); PIPE Row(spell_code('qiong', -14355)); PIPE Row(spell_code('qiu', -14353)); PIPE Row(spell_code('qu', -14345)); PIPE Row(spell_code('quan', -14170)); PIPE Row(spell_code('que', -14159)); PIPE Row(spell_code('qun', -14151)); PIPE Row(spell_code('ran', -14149)); PIPE Row(spell_code('rang', -14145));PIPE Row(spell_code('re', -14137)); PIPE Row(spell_code('ren', -14135)); PIPE Row(spell_code('reng', -14125)); PIPE Row(spell_code('ri', -14123)); PIPE Row(spell_code('rong', -14122)); PIPE Row(spell_code('rou', -14112)); PIPE Row(spell_code('ru', -14109)); PIPE Row(spell_code('ruan', -14099)); PIPE Row(spell_code('rui', -14097)); PIPE Row(spell_code('run', -14094)); PIPE Row(spell_code('ruo', -14092)); PIPE Row(spell_code('sa', -14090)); PIPE Row(spell_code('sai', -14087)); PIPE Row(spell_code('san', -14083)); PIPE Row(spell_code('sang', -13917)); PIPE Row(spell_code('sao', -13914)); PIPE Row(spell_code('se', -13910)); PIPE Row(spell_code('sen', -13907)); PIPE Row(spell_code('seng', -13906)); PIPE Row(spell_code('sha', -13905)); PIPE Row(spell_code('shai', -13896)); PIPE Row(spell_code('shan', -13894)); PIPE Row(spell_code('shang', -13878)); PIPE Row(spell_code('shao', -13870)); PIPE Row(spell_code('she', -13859)); PIPE Row(spell_code('shen', -13847)); PIPE Row(spell_code('sheng', -13831)); PIPE Row(spell_code('shi', -13658)); PIPE Row(spell_code('shou', -13611)); PIPE Row(spell_code('shu', -13601)); PIPE Row(spell_code('shua', -13406)); PIPE Row(spell_code('shuai', -13404)); PIPE Row(spell_code('shuan', -13400)); PIPE Row(spell_code('shuang', -13398)); PIPE Row(spell_code('shui', -13395)); PIPE Row(spell_code('shun', -13391)); PIPE Row(spell_code('shuo', -13387));PIPE Row(spell_code('song', -13367)); PIPE Row(spell_code('sou', -13359)); PIPE Row(spell_code('su', -13356)); PIPE Row(spell_code('suan', -13343)); PIPE Row(spell_code('sui', -13340)); PIPE Row(spell_code('sun', -13329)); PIPE Row(spell_code('suo', -13326)); PIPE Row(spell_code('ta', -13318)); PIPE Row(spell_code('tai', -13147)); PIPE Row(spell_code('tan', -13138)); PIPE Row(spell_code('tang', -13120)); PIPE Row(spell_code('tao', -13107)); PIPE Row(spell_code('te', -13096)); PIPE Row(spell_code('teng', -13095)); PIPE Row(spell_code('ti', -13091)); PIPE Row(spell_code('tian', -13076)); PIPE Row(spell_code('tiao', -13068)); PIPE Row(spell_code('tie', -13063)); PIPE Row(spell_code('ting', -13060)); PIPE Row(spell_code('tong', -12888)); PIPE Row(spell_code('tou', -12875)); PIPE Row(spell_code('tu', -12871)); PIPE Row(spell_code('tuan', -12860)); PIPE Row(spell_code('tui', -12858)); PIPE Row(spell_code('tun', -12852)); PIPE Row(spell_code('tuo', -12849)); PIPE Row(spell_code('wa', -12838)); PIPE Row(spell_code('wai', -12831)); PIPE Row(spell_code('wan', -12829)); PIPE Row(spell_code('wang', -12812)); PIPE Row(spell_code('wei', -12802)); PIPE Row(spell_code('wen', -12607)); PIPE Row(spell_code('weng', -12597)); PIPE Row(spell_code('wo', -12594)); PIPE Row(spell_code('wu', -12585)); PIPE Row(spell_code('xi', -12556)); PIPE Row(spell_code('xia', -12359));PIPE Row(spell_code('xiang', -12320)); PIPE Row(spell_code('xiao', -12300)); PIPE Row(spell_code('xie', -12120)); PIPE Row(spell_code('xin', -12099)); PIPE Row(spell_code('xing', -12089)); PIPE Row(spell_code('xiong', -12074)); PIPE Row(spell_code('xiu', -12067)); PIPE Row(spell_code('xu', -12058)); PIPE Row(spell_code('xuan', -12039)); PIPE Row(spell_code('xue', -11867)); PIPE Row(spell_code('xun', -11861)); PIPE Row(spell_code('ya', -11847)); PIPE Row(spell_code('yan', -11831)); PIPE Row(spell_code('yang', -11798)); PIPE Row(spell_code('yao', -11781)); PIPE Row(spell_code('ye', -11604)); PIPE Row(spell_code('yi', -11589)); PIPE Row(spell_code('yin', -11536)); PIPE Row(spell_code('ying', -11358)); PIPE Row(spell_code('yo', -11340)); PIPE Row(spell_code('yong', -11339)); PIPE Row(spell_code('you', -11324)); PIPE Row(spell_code('yu', -11303)); PIPE Row(spell_code('yuan', -11097)); PIPE Row(spell_code('yue', -11077)); PIPE Row(spell_code('yun', -11067)); PIPE Row(spell_code('za', -11055)); PIPE Row(spell_code('zai', -11052)); PIPE Row(spell_code('zan', -11045)); PIPE Row(spell_code('zang', -11041)); PIPE Row(spell_code('zao', -11038)); PIPE Row(spell_code('ze', -11024)); PIPE Row(spell_code('zei', -11020)); PIPE Row(spell_code('zen', -11019)); PIPE Row(spell_code('zeng', -11018)); PIPE Row(spell_code('zha', -11014)); PIPE Row(spell_code('zhai', -10838));PIPE Row(spell_code('zhan', -10832));PIPE Row(spell_code('zhang', -10815));PIPE Row(spell_code('zhao', -10800));PIPE Row(spell_code('zhe', -10790));PIPE Row(spell_code('zhen', -10780));PIPE Row(spell_code('zheng', -10764));PIPE Row(spell_code('zhi', -10587));PIPE Row(spell_code('zhong', -10544));PIPE Row(spell_code('zhou', -10533));PIPE Row(spell_code('zhu', -10519));PIPE Row(spell_code('zhua', -10331));PIPE Row(spell_code('zhuai', -10329));PIPE Row(spell_code('zhuan', -10328));PIPE Row(spell_code('zhuang', -10322));PIPE Row(spell_code('zhui', -10315));PIPE Row(spell_code('zhun', -10309));PIPE Row(spell_code('zhuo', -10307));PIPE Row(spell_code('zi', -10296));PIPE Row(spell_code('zong', -10281));PIPE Row(spell_code('zou', -10274));PIPE Row(spell_code('zu', -10270));PIPE Row(spell_code('zuan', -10262));PIPE Row(spell_code('zui', -10260));PIPE Row(spell_code('zun', -10256));PIPE Row(spell_code('zuo', -10254));Return;end;--hanjs,07-10-24,返回拼音与代码的对应关系/--此函数默认返回汉字拼音的首字母,第二个参数不为空则返回全拼。