欢迎光临
我们一直在努力

GB与BIG5内码转换COM原代码

建站超值云服务器,限时71元/月

这个com用到了一个vc的资源文件。就是字典。

大家可以去61.134.75.70/download/gb2big5.zip下载

原代码如下:

//////////////////////////////////////////

中文名称:gb与big5内码互换控件

英文名称:gb2big5

作者:blood

版本:1.0

制作时间:2002.3.5

版权所有 blood 2002 – 2003

//////////////////////////////////////////

option explicit

定义变量

dim big5data as variant

dim gbdata as variant

定义自定义类型,用来处理编码的高低字问题

type chinesetypea

lochar as byte

hichar as byte

end type

private big5type(&ha1 to &hff, &h40 to &hfe) as chinesetypea 对应于big5字库

private gbtype(&ha7 to &hff, &ha1 to &hfe) as chinesetypea 对应与gb字库

//////////////////

公共函数开始

//////////////////

big5转换到gb的函数

function big5togb(strsource as string) as string

dim i as long, y as long

定义数组,用来存放big5和gb内码数据

dim btebig5() as byte

dim btegb() as byte

如果输入的内容为空,则退出函数

if strsource = "" then

big5togb = ""

exit function

end if

将big5数组的类型从unicode编码转换为系统缺省码

btebig5 = strconv(strsource, vbfromunicode)

确定big5数组的下标,用来循环将所有的big5内容转换为gb内码

y = ubound(btebig5)

redim btegb(0 to y)

for i = 0 to y

if i = y then

btegb(i) = btebig5(i)

exit for

end if

if btebig5(i) < &ha1 or btebig5(i + 1) < &h40 then

btegb(i) = btebig5(i)

else

btegb(i) = big5type(btebig5(i), btebig5(i + 1)).lochar

btegb(i + 1) = big5type(btebig5(i), btebig5(i + 1)).hichar

i = i + 1

end if

next i

将系统缺省码转换为unicode编码

big5togb = strconv(btegb, vbunicode)

重新初始化gb数组,以释放内存

erase btegb

end function

gb转换到big5的函数

function gbtobig5(strsource as string) as string

dim i as long, y as long

定义数组,用来存放big5和gb内码数据

dim btegb() as byte

dim btebig5() as byte

如果输入的内容为空,则退出函数

if strsource = "" then

gbtobig5 = ""

exit function

end if

将gb数组的类型从unicode编码转换为系统缺省码

btegb = strconv(strsource, vbfromunicode)

确定gb数组的下标,用来循环将所有的big5内容转换为gb内码

y = ubound(btegb)

redim btebig5(0 to y)

for i = 0 to y

if i = y then

btebig5(i) = btegb(i)

exit for

end if

if btegb(i) < &ha1 or btegb(i + 1) < &ha1 then

btebig5(i) = btegb(i)

else

if btegb(i) < &hb0 and btegb(i + 1) >= &ha1 then

btebig5(i) = gbtype(btegb(i) + 6, btegb(i + 1)).lochar

btebig5(i + 1) = gbtype(btegb(i) + 6, btegb(i + 1)).hichar

else

btebig5(i) = gbtype(btegb(i), btegb(i + 1)).lochar

btebig5(i + 1) = gbtype(btegb(i), btegb(i + 1)).hichar

end if

i = i + 1

end if

next i

将系统缺省码转换为unicode编码

gbtobig5 = strconv(btebig5, vbunicode)

重新初始化big5数组,以释放内存

erase btebig5

end function

//////////////////

公共函数结束

//////////////////

类初始化

private sub class_initialize()

dim i as long

dim j as long

dim ilen as long

从资源文件中读取gb与big5的字库

gbdata = loadresdata(102, "custom") //读取gb字库

big5data = loadresdata(101, "custom") //读取big5字库

for i = &ha1 to &hfe

for j = &h40 to &hfe

big5type(i, j).lochar = big5data(ilen)

big5type(i, j).hichar = big5data(ilen + 1)

ilen = ilen + 2

next j

next i

ilen = 0

for i = &ha7 to &hfe

for j = &ha1 to &hfe

gbtype(i, j).lochar = gbdata(ilen)

gbtype(i, j).hichar = gbdata(ilen + 1)

ilen = ilen + 2

next j

next i

end sub

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » GB与BIG5内码转换COM原代码
分享到: 更多 (0)

相关推荐

  • 暂无文章