ORACLE 汉字转拼音 在数据库编码为UTF8时 正常转换

修改网上的汉字转拼音包,将部分代码替换吧

        --原来的取汉字的编码,获得高低位

        --n_ascii := ascii(v_char);
        --n_ord_high := trunc(n_ascii/256,0);
        --n_ord_low := n_ascii-(n_ord_high*256);
        --DBMS_OUTPUT.PUT_LINE('n_ascii = '||to_char(n_ascii,'9999999'));
        --DBMS_OUTPUT.PUT_LINE('n_ord_high = '||to_char(n_ord_high,'9999999'));
        --DBMS_OUTPUT.PUT_LINE('n_ord_low = '||to_char(n_ord_low,'9999999'));

        --换成新的,通过编码转换将UTF8的编码格式转换成ZHS16GBK格式的编码,获得高低位

 Select replace(substrb(dump(convert(v_char,'ZHS16GBK','UTF8'),1010),instrb(dump(convert(v_char,'ZHS16GBK','UTF8'),1010),'UTF8:')),'UTF8: ','') into lv_bytes from dual;
        li_pos:=instr(lv_bytes,',');
        n_ord_high := to_number(substr(lv_bytes,1,li_pos-1));
        n_ord_low := to_number(substr(lv_bytes,li_pos+1));

        --dbms_output.put_line(lv_bytes);
        --dbms_output.put_line(substr(lv_bytes,1,li_pos-1));
        --dbms_output.put_line(substr(lv_bytes,li_pos+1));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值