|
利用 http://www.itpub.net/thread-1217998-1-1.html
和 http://www.eygle.com/digest/2007/01/zhs16gbk_char.html
经过反复试探
insert into char_image values('HZK16.GBK',null);
declare
src_file BFILE := bfilename('DIR1', 'HZK16.GBK'); --GBK 16*16字库
dst_file BLOB;
lgh_file BINARY_INTEGER;
BEGIN
-- lock record
SELECT bin_data
INTO dst_file
FROM char_image where id='HZK16.GBK'
FOR update;
dbms_lob.createtemporary(dst_file, TRUE);
-- open the file
dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
-- determine length
lgh_file := dbms_lob.getlength(src_file);
-- read the file
dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
-- update the blob field
UPDATE char_image
SET bin_data = dst_file where id='HZK16.GBK';
COMMIT;
-- close file
dbms_lob.fileclose(src_file);
end;
/
with tmp
as(select '﹩﹪﹫〇镕镚閫閬' hz from dual),--能打出GBK增加的字,包括“〇”
tmp2
as(select level n from tmp connect by level <=length(hz)),
tmp3
as(
select n,l,--substr(dbms_lob.substr(bin_data,32,
--(ascii(to_nchar(substr(hz,n,1)))-19968)*32+1),l*4-3,4) line
case when trunc(ascii(substr(hz,n,1))/256) between to_number('A1','XX') and to_number('F7','XX')
and mod(ascii(substr(hz,n,1)),256) between to_number('A1','XX') and to_number('FE','XX') then --gb2312
substr(dbms_lob.substr(bin_data,32,(94*(trunc(ascii(substr(hz,n,1))/256)-161)+
(mod(ascii(substr(hz,n,1)),256)-161))*32+1),l*4-3,4)
when mod(ascii(substr(hz,n,1)),256) between to_number('A1','XX') and to_number('FE','XX') then --81~a0 's a1-fe
substr(dbms_lob.substr(bin_data,32,267616+32*3+(94*(trunc(ascii(substr(hz,n,1))/256)-124)+
(mod(ascii(substr(hz,n,1)),256)-161))*32+1),l*4-3,4)
else --81~fe's 40~7e 80~a0
substr(dbms_lob.substr(bin_data,32,267616+32*3+(160-128)*94*32-10*32+(96*(trunc(ascii(substr(hz,n,1))/256)-124)+
(mod(ascii(substr(hz,n,1)),256)-64-trunc(mod(ascii(substr(hz,n,1)),256)/128)))*32+1),l*4-3,4)
end line
from char_image,tmp,tmp2 ,
(select level l from dual connect by level<=16) where id='HZK16.GBK'),
tmp4
as(
select n,l,to_number(substr(line,1,1),'X')a,to_number(substr(line,2,1),'X')b,
to_number(substr(line,3,1),'X')c,to_number(substr(line,4,1),'X')e from tmp3)
select --n,l,a,b,c,e,
replace(replace(
to_char(
(floor(a/8)||mod(floor(a/4),2)||mod(floor(a/2),2)||mod(a,2))*1E12+
(floor(b/8)||mod(floor(b/4),2)||mod(floor(b/2),2)||mod(b,2))*1E8+
(floor(c/8)||mod(floor(c/4),2)||mod(floor(c/2),2)||mod(c,2))*1E4+
(floor(e/8)||mod(floor(e/4),2)||mod(floor(e/2),2)||mod(e,2)),'09999999999999999'),
'0',' '),'1','■') hh from tmp4
order by n,l;
------------------------------------------------------------------------
■
■
■■■■■
■ ■ ■■
■ ■ ■■
■ ■
■■■■
■ ■
■ ■ ■
■ ■ ■
■ ■ ■
■■■■■
■
■
■
■■ ■
■ ■ ■
■ ■ ■
■ ■ ■
■■ ■ ■■
■ ■ ■
■ ■ ■
■ ■ ■
■ ■■
■■■■■
■ ■
■ ■■ ■
■ ■ ■ ■
■ ■ ■ ■
■ ■ ■ ■
■ ■■■ ■
■ ■■ ■
■ ■
■■■■■■
■
■■■ ■■
■ ■■
■■ ■
■ ■
■ ■
■ ■
■ ■
■ ■
■
■ ■
■■■■■■■
■ ■
■ ■
■ ■■■■■■■■■
■■■■ ■ ■
■ ■ ■ ■
■ ■ ■
■■■■■■ ■ ■
■ ■ ■
■ ■ ■
■■■■■■ ■ ■■
■ ■ ■■■■■■
■ ■ ■
■ ■ ■ ■
■■ ■ ■
■ ■■■■■
■ ■
■ ■
■ ■ ■ ■
■ ■ ■ ■
■■■■ ■■■■■■■■
■
■ ■■■■ ■■■■
■■■■■■ ■ ■ ■
■ ■ ■ ■ ■ ■
■ ■■■■ ■■■■
■■■■■■■ ■ ■ ■
■ ■■■■ ■■■■
■ ■ ■ ■ ■
■ ■■ ■ ■ ■
■■ ■ ■ ■ ■
■ ■ ■■ ■ ■
■ ■ ■
■■■■■ ■■■■■
■ ■ ■ ■
■■■■■ ■■■■■
■ ■ ■ ■
■■■■■ ■■■■■
■ ■
■ ■■■■■■■ ■
■ ■ ■ ■ ■
■ ■■■■■■■ ■
■ ■ ■■■ ■ ■
■ ■■ ■ ■■ ■
■ ■ ■ ■ ■
■ ■■■■■■■ ■
■ ■ ■
■ ■
■■■■■■ ■■■■■■
■ ■ ■ ■
■■■■■■ ■■■■■■
■ ■ ■ ■
■■■■■■■ ■■■■■■
■ ■ ■
■ ■■■■■■ ■
■ ■ ■ ■
■ ■■■■■■ ■
■ ■ ■ ■
■ ■■■■■■ ■
■ ■ ■ ■ ■
■ ■ ■■ ■
■ ■■■ ■ ■
■ ■ ■ ■ ■
■ ■
已选择128行。
|
|