第一个函数把HTML中的数据转成HTML实体, 而HTML标签则自动不转, 这样无论到哪里都不会乱码, 可以在发送邮件时选择发送HTML格式的邮件. 第二个函数把JS数据同样是换成转义字符, 同样避开了JS关键词等字符的转换, 不管网页是什么编码它都不会乱码. 废话少说, 看下面的代码. 复制代码 代码如下: Function htmlentities(str) Dim a,i,char For i = 1 to Len(str) char = mid(str, i, 1) a=Ascw(char) If a > 128 Or a < 0 then htmlentities = htmlentities & “” & clng(”&h” & hex((Ascw(char)))) & “;” Else htmlentities = htmlentities & char End if Next End Function
Function Unicode(str1) Dim str,temp str = “” For i=1 To Len(str1) temp = Hex(AscW(Mid(str1,i,1))) If len(temp) < 5 Then temp = Right(”0000″ & temp, 4) str = str & “u” & temp Next Unicode = str End Function