好象转成16进制就可以了
;===============================================================================
; 说明: 二进制转换为十六进制
; 语法: _BinaryToHex($sBinStr[, $iLength = 0])
; 参数: $sBinStr - 需要转换的二进制字符
; $iLength - [可选] 返回长度
; 需要: 无
; 返回: 成功 - 十六进制字符
; 失败 - 空字符 "", 并设置 @error 到 1
; 备注: 限制: 输入最大 2147483647 个字符
;===============================================================================
Func _BinaryToHex($sBinStr, $iLength = 0)
Local $sHexStr = ""
If NOT StringRegExp($sBinStr, "^[01]+$") Then Return SetError(1, 0, "")
While Mod(StringLen($sBinStr), 4)
$sBinStr = "0" & $sBinStr
WEnd
For $i = 1 To StringLen($sBinStr) Step 4
Switch StringMid($sBinStr, $i, 4)
Case "0000"
$sHexStr &= "0"
Case "0001"
$sHexStr &= "1"
Case "0010"
$sHexStr &= "2"
Case "0011"
$sHexStr &= "3"
Case "0100"
$sHexStr &= "4"
Case "0101"
$sHexStr &= "5"
Case "0110"
$sHexStr &= "6"
Case "0111"
$sHexStr &= "7"
Case "1000"
$sHexStr &= "8"
Case "1001"
$sHexStr &= "9"
Case "1010"
$sHexStr &= "A"
Case "1011"
$sHexStr &= "B"
Case "1100"
$sHexStr &= "C"
Case "1101"
$sHexStr &= "D"
Case "1110"
$sHexStr &= "E"
Case "1111"
$sHexStr &= "F"
EndSwitch
Next
If $iLength = 0 Then
While StringLeft($sHexStr, 1) = "0"
$sHexStr = StringTrimLeft($sHexStr, 1)
WEnd
Else
For $i = 1 To $iLength - StringLen($sHexStr)
$sHexStr = "0" & $sHexStr
Next
EndIf
Return $sHexStr
EndFunc ;==>_BinaryToHex
|