宝玉

专注于web开发技术
随笔 - 114, 评论 - 1516 , 引用 - 583

Unicode 转义序列

有时候需要将文字变成Unicode 转义序列

Js版

<script>
test = "你好abc"

str = ""
for( i=0; i<test.length; i++ )
{
 temp = test.charCodeAt(i).toString(16);
 str += "\\u"+ new Array(5-String(temp).length).join("0") +temp;
}
document.write (str)
</script>

vbs版

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

 

发表于 2004年7月5日 10:44

评论

# re: Unicode 转义序列

谢谢!
2005-3-7 9:21 | 师域

# re: Unicode 转义序列

3x。宝玉
2005-5-9 21:40 | 阿浪

# re: Unicode 转义序列

请问解密的vb函数是什么 呢?
2006-12-12 4:58 | fish

Post Comment

主题  
姓名  
主页
校验码  
内容   
京ICP备 05050892号