是ASP,不是.net,谢谢大家
3 个解决方案
#1
string oldHtml = GetYourGB2312Html();
Encoding encoding;
encoding = System.Text.Encoding.GetEncoding( "GB2312 ");
byte[] bytes = encoding.GetBytes(oldHtml);
encoding = System.Text.Encoding.UTF8;
string newOldHtml = encoding.GetString(bytes);
//Response.Write(newOldHtml);
这样就可以把gb2312转成utf8了
Encoding encoding;
encoding = System.Text.Encoding.GetEncoding( "GB2312 ");
byte[] bytes = encoding.GetBytes(oldHtml);
encoding = System.Text.Encoding.UTF8;
string newOldHtml = encoding.GetString(bytes);
//Response.Write(newOldHtml);
这样就可以把gb2312转成utf8了
#2
Function GBUrlEncode(var)
Session.codepage=936
GBUrlEncode=server.urlencode(var)
Session.Codepage=65001
end Function
Session.codepage=936
GBUrlEncode=server.urlencode(var)
Session.Codepage=65001
end Function
#3
Function GBtoUTF8(szInput)
Dim wch, uch, szRet
Dim x
Dim nAsc, nAsc2, nAsc3
'如果输入参数为空,则退出函数
If szInput = "" Then
GBtoUTF8= szInput
Exit Function
End If
'开始转换
For x = 1 To Len(szInput)
wch = Mid(szInput, x, 1)
nAsc = AscW(wch)
If nAsc < 0 Then nAsc = nAsc + 65536
If (nAsc And &HFF80) = 0 Then
szRet = szRet & wch
Else
If (nAsc And &HF000) = 0 Then
uch = "%" & Hex(((nAsc \ 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80)
szRet = szRet & uch
Else
uch = "%" & Hex((nAsc \ 2 ^ 12) Or &HE0) & "%" & _
Hex((nAsc \ 2 ^ 6) And &H3F Or &H80) & "%" & _
Hex(nAsc And &H3F Or &H80)
szRet = szRet & uch
End If
End If
Next
GBtoUTF8= szRet
End Function
ASP读写文件并转码
#1
string oldHtml = GetYourGB2312Html();
Encoding encoding;
encoding = System.Text.Encoding.GetEncoding( "GB2312 ");
byte[] bytes = encoding.GetBytes(oldHtml);
encoding = System.Text.Encoding.UTF8;
string newOldHtml = encoding.GetString(bytes);
//Response.Write(newOldHtml);
这样就可以把gb2312转成utf8了
Encoding encoding;
encoding = System.Text.Encoding.GetEncoding( "GB2312 ");
byte[] bytes = encoding.GetBytes(oldHtml);
encoding = System.Text.Encoding.UTF8;
string newOldHtml = encoding.GetString(bytes);
//Response.Write(newOldHtml);
这样就可以把gb2312转成utf8了
#2
Function GBUrlEncode(var)
Session.codepage=936
GBUrlEncode=server.urlencode(var)
Session.Codepage=65001
end Function
Session.codepage=936
GBUrlEncode=server.urlencode(var)
Session.Codepage=65001
end Function
#3
Function GBtoUTF8(szInput)
Dim wch, uch, szRet
Dim x
Dim nAsc, nAsc2, nAsc3
'如果输入参数为空,则退出函数
If szInput = "" Then
GBtoUTF8= szInput
Exit Function
End If
'开始转换
For x = 1 To Len(szInput)
wch = Mid(szInput, x, 1)
nAsc = AscW(wch)
If nAsc < 0 Then nAsc = nAsc + 65536
If (nAsc And &HFF80) = 0 Then
szRet = szRet & wch
Else
If (nAsc And &HF000) = 0 Then
uch = "%" & Hex(((nAsc \ 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80)
szRet = szRet & uch
Else
uch = "%" & Hex((nAsc \ 2 ^ 12) Or &HE0) & "%" & _
Hex((nAsc \ 2 ^ 6) And &H3F Or &H80) & "%" & _
Hex(nAsc And &H3F Or &H80)
szRet = szRet & uch
End If
End If
Next
GBtoUTF8= szRet
End Function
ASP读写文件并转码