好像没有判断一个字符是全角还是半角的函数。
但有转换函数: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/