国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP UTF-8頁面亂碼+GB2312轉(zhuǎn)UTF-8 +生成UTF-8格式的文件(編碼)第1/2頁

2024-05-04 10:57:20
字體:
供稿:網(wǎng)友
最好的方法:
先說一下基本的東西:
<%@ codepage=65001%>UTF-8
<%@ codepage=936%>簡體中文
<%@ codepage=950%>繁體中文
<%@ codepage=437 %>美國/加拿大英語
<%@ codepage=932 %>日文
<%@ codepage=949 %>韓文
<%@ codepage=866 %>俄文

codepage指定了IIS按什么編碼讀取傳遞過來的串串(表單提交,地址欄傳遞等)。

出亂碼的原因也就是網(wǎng)站要整合的時候模塊編碼不相同引起的。
就像我的博客相同,整合的時候都會出這個問題,因為BLOG是Utf-8的,
近來很多網(wǎng)友都在為這個問題咨詢,我嘗試了很多種方法。
最方便的方法如下:
不要轉(zhuǎn)換任何模塊網(wǎng)頁的編碼該utf-8的還是utf-8,該Gb22312的還是Gb2312
在Utf-8模塊的包文檔(如conn.asp,但是要注意conn.asp必須是在第一行調(diào)用)最前面加上
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Session.CodePage=65001%>
在GB2312模塊的包文檔最前面加上
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%Session.CodePage=936%>
其他編碼的類推。
ASP中漢字與UTF-8的互相轉(zhuǎn)換
'=============漢字轉(zhuǎn)換為UTF-8==================

function chinese2unicode(Str)
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
chinese2unicode = Str_unicode
end function



'=============UTF-8轉(zhuǎn)換為漢字==================

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))))
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 泸定县| 慈利县| 泾川县| 呼和浩特市| 永胜县| 永宁县| 威远县| 合江县| 商丘市| 黔南| 进贤县| 苗栗市| 巴彦淖尔市| 长治县| 福泉市| 张掖市| 芒康县| 麦盖提县| 曲松县| 星座| 嫩江县| 迁西县| 柳河县| 周宁县| 广德县| 监利县| 连江县| 镶黄旗| 库车县| 平舆县| 临江市| 佛冈县| 怀化市| 临湘市| 集贤县| 定南县| 海南省| 江达县| 航空| 淳安县| 乐昌市|