http://pixy.cn/utf8.asp

无论网页是G2312还是其他编码将汉字转换后都可以正常显示

例子:“汉字”转换后为: 汉字

写入库为汉字这种码需要保存页为:

CODEPAGE="65001"

Session.CodePage=65001

Response.CharSet="UTF-8"

还要使用:server.HTMLEncode 如:

content=server.HTMLEncode(request.form("content"))

server.HTMLEncode把特殊字符也做了转换所以要:

'=====反转换HTML代码=====
Function HTMLDecode(ByVal reString)
 Dim Str:Str=reString
 If Not IsNull(Str) Then
  Str = Replace(Str, ">", ">")
  Str = Replace(Str, "&lt;", "<")
  Str = Replace(Str, "&lt;", "<")
     Str = Replace(Str, "&amp;", "&")
  Str = Replace(Str, "    ", CHR(9))
  Str = Replace(Str, "'", CHR(39))
  Str = Replace(Str, "&quot;", CHR(34))
  Str = Replace(Str, "", CHR(13))
  'Str = Replace(Str, "<br />", CHR(10))
  HTMLDecode = Str
 End If
End Function