请教: 二进制转为字符串(包括中文)
btbtd 2006-09-25 03:46:02
二进制转为 ASCII, 这个没问题, 但是 二进制中包括中文的转换目前不知道咋弄呀.
这是个什么原理, 有没有相关的资料可参考一下,,,我再弄了一会, 晕得要命.
我将字符串 "test_中文测试" 转为二进制, 再用转二进制为ASCII的方法转换:
出现如下结果:
start test
t 116
e 101
s 115
t 116
_ 95
ä 228
¸ 184
173
æ 230
150
135
æ 230
µ 181
139
è 232
¯ 175
149
13
10
ꏠ
end test
fPrefix= test_______ (_是中文字符)
可见一个中文字符为三个ASCII
对应:
20013(unicode 码)
ä 228
¸ 184
173
中
25991(unicode 码)
æ 230
150
135
文
27979(unicode 码)
æ 230
µ 181
139
测
-29739(unicode 码)
è 232
¯ 175
149
试
没直接转换为二进制的测试:
<%
dim str
str="test_中文测试"
dim i
for i=1 to len(Str)
response.write ascW(mid(str,i,1))
response.write "<br/>"
next
response.write chrW(20013)
response.write chrW(25991)
response.write chrW(27979)
response.write chrW(-29739)
%>
说了这么多, 基本上全废话.
我想知道的是, 如何正确的转换包括中文的二进制流, 特别是原理.
谢谢!