ASP做网页时,显示汉字的编码有问题时要进行UTF-8及GB2312转换。请大家参考
ASP汉字编码转换UTF-8及UTF-8转换GB2312
function chinese2unicode(Str)
dim i
dim Str_one
dim Str_unicode
for i=1 to len(Str)
Str_one=Mid(Str,i,1)
Str_unicode=Str_unicode&chr(38)
Str_unicode=Str_unicode&chr(35)
Str_unicode=Str_unicode&chr(120)
Str_unicode=Str_unicode& Hex(ascw(Str_one))
Str_unicode=Str_unicode&chr(59)
next
Response.Write Str_unicode
end function
UTF-8 To GB2312
function UTF2GB(UTFStr)
for Dig=1 to len(UTFStr)
if mid(UTFStr,Dig,1)="%" then
if len(UTFStr) >= Dig+8 then
GBStr=GBStr & ConvChinese(mid(UTFStr,Dig,9))
Dig=Dig+8
else
GBStr=GBStr & mid(UTFStr,Dig,1)
end if
else
GBStr=GBStr & mid(UTFStr,Dig,1)
end if
next
UTF2GB=GBStr
end function
function ConvChinese(x)
A=split(mid(x,2),"%")
i=0
j=0
for i=0 to ubound(A)
A(i)=c16to2(A(i))
next
for i=0 to ubound(A)-1
DigS=instr(A(i),"0")
Unicode=""
for j=1 to DigS-1
if j=1 then
A(i)=right(A(i),len(A(i))-DigS)
Unicode=Unicode & A(i)
else
i=i+1
A(i)=right(A(i),len(A(i))-2)
Unicode=Unicode & A(i)
end if
next
if len(c2to16(Unicode))=4 then
ConvChinese=ConvChinese & chrw(int("&H" & c2to16(Unicode)))
else
ConvChinese=ConvChinese & chr(int("&H" & c2to16(Unicode)))
end if
next
end function
function c2to16(x)
i=1
for i=1 to len(x) step 4
c2to16=c2to16 & hex(c2to10(mid(x,i,4)))
next
end function
function c2to10(x)
c2to10=0
if x="0" then exit function
i=0
for i= 0 to len(x) -1
if mid(x,len(x)-i,1)="1" then c2to10=c2to10+2^(i)
next
end function
function c16to2(x)
i=0
for i=1 to len(trim(x))
tempstr= c10to2(cint(int("&h" & mid(x,i,1))))
do while len(tempstr)<4
tempstr="0" & tempstr
loop
c16to2=c16to2 & tempstr
next
end function
function c10to2(x)
mysign=sgn(x)
x=abs(x)
DigS=1
do
if x<2^DigS then
exit do
else
DigS=DigS+1
end if
loop
tempnum=x
i=0
for i=DigS to 1 step-1
if tempnum>=2^(i-1) then
tempnum=tempnum-2^(i-1)
c10to2=c10to2 & "1"
else
c10to2=c10to2 & "0"
end if
next
if mysign=-1 then c10to2="-" & c10to2
end function
ASP UTF-8页面乱码+GB2312转UTF-8 +生成UTF-8格式的文件(编码)_IT/计算机...ASP 中汉字与 UTF-8 的互相转换 '===汉字转换为 UTF-8=== function chinese...
ASP 编码转换大全 UTF8、GB2312、二进制、十进制代码、十六进制_IT/计算机_专业资料。'UTF转GB---将UTF8编码文字转换为GB编码文字 function UTF2GB(UTFStr) ...
GB2312编码、日文编码等也是非unicode编码,是要通过转换表(codepage)转换成...xxxxxx 10xxxxxx 10xxxxxx 下面,还是以汉字“严”为例,演示如何实现UTF-8编码...
UTF-8 一个汉字, 3 个字节, UNICODE 用 2 个... 01.// 把 UTF-8 转换成 Unicode 02.void 03.... UTF-8与GB2312互转 1页 免费 ASP 编码转换大全...
字符集之间转换(UTF-8,UNICODE,Gb2312)_IT/... // 把UTF-8转换成Unicode static void ... 清华附中文科学霸高中政治笔记 东北师大附中理科学...
GBK包含全部中文字符,是国家编码,通用性比UTF8差,不过UTF8占用的数据库比GBD大。 GBK、GB2312等与UTF8之间都必须通过Unicode编码才能相互转换: GBK、GB2312--...
c_实现GB2312和UTF8字符编码方式的转换_工学_高等教育_教育专区。public ...Encoding.Default 在 简体中文 os 中一般是 gb2312 格式。 今日推荐 ...
GBK 包含全部中文字符,是国家编码,通用性比 UTF8差,不过 UTF8占用的数据库比 GBD 大。 GBK、GB2312等与 UTF8之间都必须通过 Unicode 编码才能相互转换: GBK、...
GB2312和 GBK 编码标准中,存储方法 兼容 ASCII,汉字占用两个字节。2000年和...UTF-8、UTF-16、UTF-32都是将 Unicode 标准中的码位转换到具体存储数据的...
热门文档