我想将"韩"字先转化为二进制数据,再转化为字符,怎么办呢?

hayseed 2003-08-25 07:39:53
我是这样写的:
Function BinaryToString(str)
strto = ""
for i=1 to lenb(str)
if AscB(MidB(str, i, 1)) > 127 then
strto = strto & chr(Ascb(MidB(str, i, 1))*256+Ascb(MidB(str, i+1, 1)))
i = i + 1
else
strto = strto & Chr(AscB(MidB(str, i, 1)))
end if
next
BinaryToString=strto
End Function

response.write BinarytoString(chrb(AscB(midB("韩",1,1)))
& chrb(AscB(midB("韩",2,1))))

结果是个"闂"字.
其实如果将"韩"改为"abcd",以上代码是没有问题的.
请指教!

注:各位若要调试,请勿直接粘贴代码,会出错的.
...全文
87 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
up
anita2li 2003-08-26
  • 打赏
  • 举报
回复
UP
  • 打赏
  • 举报
回复
---------------------------------汉字判断-----------------------------------
function isChinese(para)
on error resume next
dim str
dim i
if isNUll(para) then
isChinese=false
exit function
end if
str=cstr(para)
if trim(str)="" then
isChinese=false
exit function
end if
for i=1 to len(str)
c=asc(mid(str,i,1))
if c>=0 then
isChinese=false
exit function
end if
next
isChinese=true
if err.number<>0 then err.clear
end function
%>
----------------------------------------------------------------------------




-----------------------替换指定文件内字符串的函数---------------------------
<%
function FSOlineedit(filename,Target,String)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FiletempData = objCountFile.ReadAll
objCountFile.Close
FiletempData=Replace(FiletempData,Target,String)
Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)
objCountFile.Write FiletempData
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
End Function
response.write FSOlineedit("test.txt","世界","明天是一个好天去")
%>
----------------------------------------------------------------------------

--------------------获取中文字符串拼音首字母串的函数------------------------
<%
response.write "<link href=style.css rel=stylesheet>"
if request.form("content")="" then
response.write "<center><form method=post action=asd.asp><input name=content type=text>__<input type=submit></form>"
else
function getpychar(char)
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) then
getpychar= "A"
elseif(tmp>=45253 and tmp<=45760) then
getpychar= "B"
elseif(tmp>=45761 and tmp<=46317) then
getpychar= "C"
elseif(tmp>=46318 and tmp<=46825) then
getpychar= "D"
elseif(tmp>=46826 and tmp<=47009) then
getpychar= "E"
elseif(tmp>=47010 and tmp<=47296) then
getpychar= "F"
elseif(tmp>=47297 and tmp<=47613) then
getpychar= "G"
elseif(tmp>=47614 and tmp<=48118) then
getpychar= "H"
elseif(tmp>=48119 and tmp<=49061) then
getpychar= "J"
elseif(tmp>=49062 and tmp<=49323) then
getpychar= "K"
elseif(tmp>=49324 and tmp<=49895) then
getpychar= "L"
elseif(tmp>=49896 and tmp<=50370) then
getpychar= "M"
elseif(tmp>=50371 and tmp<=50613) then
getpychar= "N"
elseif(tmp>=50614 and tmp<=50621) then
getpychar= "O"
elseif(tmp>=50622 and tmp<=50905) then
getpychar= "P"
elseif(tmp>=50906 and tmp<=51386) then
getpychar= "Q"
elseif(tmp>=51387 and tmp<=51445) then
getpychar= "R"
elseif(tmp>=51446 and tmp<=52217) then
getpychar= "S"
elseif(tmp>=52218 and tmp<=52697) then
getpychar= "T"
elseif(tmp>=52698 and tmp<=52979) then
getpychar= "W"
elseif(tmp>=52980 and tmp<=53640) then
getpychar= "X"
elseif(tmp>=53689 and tmp<=54480) then
getpychar= "Y"
elseif(tmp>=54481 and tmp<=62289) then
getpychar= "Z"
else '如果不是中文,则不处理
getpychar=char
end if
end function
function getpy(str)
for i=1 to len(str)
getpy=getpy&getpychar(mid(str,i,1))
next
end function
content=request.form("content")
response.write "<center>"&getpy(content)&chr(10)
response.write "<br><br><br><a href=# onclick=javascript:history.go(-1)>返回</a>"
end if
%>

去研究一下 会有帮助 也许

28,391

社区成员

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

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