Oracle 生僻字乱码解决方案
Oracle 生僻字乱码解决方案
" "(此+夕)【 su ǒ】字乱码,无法正常显示(变成问号);
生僻字" "(此 + 夕) (suo) 在 ZHS16GBK 字符集下默认无法正常显示;
测试将生僻字类型由 varchar2 改成 nvarchar2 ,同时使用 utl_raw.cast_to_nvarchar2 函数可以在数据库里正常显示;
select * from t1;
数据库字符集如下:
select * from nls_database_parameters;
T1 表结构如下:
A 字段为 VARCHAR2 类型
http://tool.chinaz.com/tools/unicode.aspx
---将生僻字生成对应的unicode编码
select utl_raw.cast_to_varchar2('3C54') from dual;
select utl_raw.cast_to_nvarchar2('3C54') from dual;
--- 测试 varchar2 类型无法正常存储生僻字 " "
truncate table t1;
alter table t1 modify (a nvarchar2(100));
insert into t1 values('? ' ,1);
select * from t1;
update t1
set a =
(select utl_raw.cast_to_nvarchar2('3C54') from dual)
where b = 1;
select * from t1;
--- 测试 nvarchar2 类型可以正常存储生僻字 " '
truncate table t1;
alter table t1 modify (a nvarchar2(100));
insert into t1 values('? ' ,1);
select * from t1;
update t1
set a =
(select utl_raw.cast_to_nvarchar2('3C54') from dual)
where b = 1;
select * from t1;
欢迎关注我的微信公众号"IT小Chen",共同学习,共同成长!!!