请问,如何将unicode编码转换成汉字啊??

sunlinwh 2004-08-08 06:07:12

请问,如何将unicode编码转换成汉字啊??

看着像乱友,但的确是中文字符,请问我该如何转换过来呢?

谢谢!!!
...全文
518 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
threezxw 2004-08-09
  • 打赏
  • 举报
回复
学习

to_be_or_not_to_be 2004-08-09
  • 打赏
  • 举报
回复
Unicode编码有多种方法
字符串编码:
1、&#x****;这样是Unicode的十六进制编码
2、&#*****;这样是直接进行Unicode编码
文件编码:
头两个字符:&HFF和&HFE,双字节编码,不足两位右补Chr(0)
字符串编码里的十六进制编码用aspzclover的程序可以解码

文件编码用这个解码,binIn参数是byte型数据,用adodb.stream的read函数可以获取文件的byte流:

Dim st: Set st = CreateObject("adodb.stream")
st.Type = 1
st.Open
st.LoadFromFile "1.xml"
Dim db: db = st.Read(-1)
st.Close
Set st = Nothing

WScript.echo ConvertUnicode(db)
Function ConvertUnicode(binIn)
Dim bl: bl = LenB(binIn)
Dim i
If bl<2 Then'Unicode编码的文件,头两个字符是&HFF和&HFE,如果总长度都少于2,那么就不是Unicode编码的文件
ConvertUnicode = binIn
Exit Function
End If
Dim f_c: f_c = Hex(AscB(MidB(binIn, 1, 1)))
Dim e_c: e_c = Hex(AscB(MidB(binIn, 2, 1)))
If (f_c="FF" And e_c="FE")=False Then'如果头两个字符不是&HFF和&HEE,则不是Unicode编码的文件
ConvertUnicode = binIn
Exit Function
End If
ConvertUnicode = ""
For i=3 to bl step 2'从第三位起开始解析Unicode编码的文件,步长为2
Dim c: c = MidB(binIn, i, 2)
ConvertUnicode = ConvertUnicode & c
Next
End Function
yexing 2004-08-08
  • 打赏
  • 举报
回复
用ie打开,拷贝到剪贴板,保存到文本文件:)
sunlinwh 2004-08-08
  • 打赏
  • 举报
回复
谢谢楼上的朋友,能给我写个asp的函数吗?

aspczlover 2004-08-08
  • 打赏
  • 举报
回复
<script>
function UnicodeDecode(strIn){
var s_k = "&#x";
var e_k = ";";
var s_l = strIn.indexOf(s_k);
var e_l = 0;
var sOut = "";
var i = 0;
sOut += strIn.substring(0, s_l);
while(s_l!=-1){
e_l = strIn.indexOf(e_k, s_l);
var t = strIn.substring(s_l+s_k.length, e_l);
t = String.fromCharCode(parseInt("0x" + t));
sOut += t;
s_l = strIn.indexOf(s_k, e_l);
if (s_l!=-1&&s_l-1!=e_l) sOut += strIn.substring(e_l+1, s_l);
if (i++>5) break;
}
e_l = e_l!=0?e_l+1:e_l;
sOut += strIn.substring(e_l, strIn.length);
return sOut;
}

</script>

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧