实现UTF8转换GB2312国标码的asp代码
程序员文章站
2022-06-05 12:25:40
复制代码 代码如下: '个人代码风格注释(变量名中第一个小写字母表表示变量类型) 'i:为integer型; 's:为string; function u2utf8(byv...
复制代码 代码如下:
'个人代码风格注释(变量名中第一个小写字母表表示变量类型)
'i:为integer型;
's:为string;
function u2utf8(byval a_inum)
dim sresult,sutf8
dim itemp,ihexnum,i
ihexnum = trim(a_inum)
if ihexnum = “” then
exit function
end if
sresult = “”
if (ihexnum < 128) then
sresult = sresult & ihexnum
elseif (ihexnum < 2048) then
sresult = chrb(&h80 + (ihexnum and &h3f))
ihexnum = ihexnum \ &h40
sresult = chrb(&hc0 + (ihexnum and &h1f)) & sresult
elseif (ihexnum < 65536) then
sresult = chrb(&h80 + (ihexnum and &h3f))
ihexnum = ihexnum \ &h40
sresult = chrb(&h80 + (ihexnum and &h3f)) & sresult
ihexnum = ihexnum \ &h40
sresult = chrb(&he0 + (ihexnum and &hf)) & sresult
end if
u2utf8 = sresult
end function
function gb2utf(byval a_sstr)
dim sgb,sresult,stemp
dim ilen,iunicode,itemp,i
sgb = trim(a_sstr)
ilen = len(sgb)
for i = 1 to ilen
stemp = mid(sgb,i,1)
itemp = asc(stemp)
if (itemp>127 or itemp<0) then
iunicode = ascw(stemp)
if iunicode<0 then
iunicode = iunicode + 65536
end if
else
iunicode = itemp
end if
sresult = sresult & u2utf8(iunicode)
next
gb2utf = sresult
end function
'调用方法
response.binarywrite(gb2utf(“中国人”))
上一篇: 香椿什么时候不能吃,懂科学才能吃出健康
下一篇: 慈禧第一次看到电灯,说了一句什么话?
推荐阅读
-
在ASP.Net中实现flv视频转换的代码
-
实现UTF8转换GB2312国标码的asp代码
-
asp下实现对HTML代码进行转换的函数
-
FormatRemoteUrl函数之asp实现格式化成当前网站完整的URL-将相对地址转换为绝对地址的代码
-
https,https的本地测试环境搭建,asp.net结合https的代码实现,http网站转换成https网站之后遇到的问题
-
asp下实现UrlEncoding转换编码的代码
-
asp在服务器把 XML 转换为 XHTML的实现代码
-
ASP实现GB2312字符与区位码的相互转换的代码
-
php进行GB2312与UTF8编码转换的代码
-
实现UTF8转换GB2312国标码的asp代码