全角半角字符转换(补:字符集convert转换)

好像没有判断一个字符是全角还是半角的函数。

但有转换函数:TO_MULTI_BYTE(string) 和 TO_SINGLE_BYTE(string)。还有一个TRANSLATE(string, from, to)也可以派上用场。


SQL> select to_multi_byte('abc123(),./;'':"[]{}|') from dual;

TO_MULTI_BYTE('ABC123(),./;'':"[]{}|')
------------------------------------------
abc123(),./;':"[]{}\|

SQL> select to_single_byte('abc123(),./;':"[]{}\|') from dual;

TO_SINGLE_BYTE('AB
---------------------
abc123(),./;':"[]{}|

SQL> select translate('abc123', 'abc', 'abc') from dual;

TRANSLATE
---------
abc123


补:字符集convert转换

The syntax of the convert function is:

convert( string1 , char_set_to , [ char_set_from ] )

  • string1 is the string to be converted.
  • char_set_to is the character set to convert to.
  • char_set_from is the character set to convert from.

简单举例如下:

SQL> select dump( convert('我', 'utf8') , 1016) from dual;

DUMP(CONVERT('我','UTF8'),1016)
-------------------------------------------
Typ=1 Len=3 CharacterSet=ZHS16GBK: e6,88,91

SQL> select convert( convert('我', 'utf8'), 'zhs16gbk', 'utf8') from dual;

CO
--

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9844649/viewspace-579998/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9844649/viewspace-579998/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值