0

Vbscript实现Hex(十六进制)与Ascii码互转

Posted by 晴云孤魂 on 2012 年 02 月 10 日 in windows Script Design |
   nums = a2h("中国A")    
WScript.Echo nums    h2a(nums)
Function a2h(s)
    Dim i    
For i = 1 To Lenb(s) Step 2        
a2h = a2h & Hex(Ascb(Midb(s,i,1))) & Space(1) & Hex(Ascb(Midb(s,i+1,1))) & Space(1)    
Next
End Function
Function h2a(s)
    Dim arr    
Dim i    
arr = Split(RTrim(s))    
For i = 0 To UBound(arr) Step 2       
 WScript.Echo ChrW(CInt("&H" & arr(i+1)) * 256 + CInt("&H" & arr(i)))    
Next
End Function

Copyright © 2011-2024 晴云孤魂's Blog All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.

普人特福的博客cnzz&51la for wordpress,cnzz for wordpress,51la for wordpress