jpm Posted September 3, 2005 Posted September 3, 2005 I don't think these functions should return errors on "" string. if the string is "" both functions should return "". I think there is an bug on malform hexstring when converting to string as no checking is done=============================================================================== ; ; Function Name: _HexToStr("hex") ; Description: Convert a hex string of characters to ASCII Characters. ; Parameter(s): $strHex is the hex string you want to convert. ; Requirement(s): Hex Input. ; Return Value(s): On Success - Returns the converted string of characters. ; On Failure - -1 and sets @ERROR = 1 ; Author(s): Jarvis Stubblefield ; Corrrected jpm ; ;=============================================================================== Func _HexToString($strHex) Local $strChar, $aryHex, $i, $iDec, $Char, $file, $iOne, $iTwo $aryHex = StringSplit($strHex, "") For $i = 1 To $aryHex[0] $iOne = $aryHex[$i] $i = $i + 1 $iTwo = $aryHex[$i] $iDec = Dec($iOne & $iTwo) If @error <>0 Then SetError(1) return -1 EndIf $Char = Chr($iDec) $strChar = $strChar & $Char Next Return $strChar EndFunc ;=============================================================================== ; ; Function Name: _StrToHex("string") ; Description: Convert a string of characters to hexidecimal. ; Parameter(s): $strChar is the string you want to convert. ; Requirement(s): String Input. ; Return Value(s): Returns the converted string in hexidecimal. ; ; Author(s): Jarvis Stubblefield ; Corrrected jpm ; ;=============================================================================== Func _StringToHex($strChar) Local $aryChar, $i, $iDec, $hChar, $file, $strHex $aryChar = StringSplit($strChar, "") For $i = 1 To $aryChar[0] $iDec = Asc($aryChar[$i]) $hChar = Hex($iDec, 2) $strHex = $strHex & $hChar Next Return $strHex EndFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now