Kickassjoe Posted March 31, 2010 Posted March 31, 2010 (edited) So, when parsing this: 32347C35397C32312C300032357C3132393033307C382C32343338367C392C317C39392C350033307C317C312C302C302E30302C302C312C352C302C317C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C312C302C302C302C302C302C3000With a _hexToString, I get: 24|59|21,0 But, when I translate that into 2 strings: 32347C35397C32312C300032357C3132393033307C382C32343338367C392C317C39392C35 AND 33307C317C312C302C302E30302C302C312C352C302C317C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C312C302C302C302C302C302C3000 I get: 24|59|21,0 AND 30|1|1,0,0.00,0,1,5,0,1|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0 Could I get any insight into why this is happening like this, and what I can do to get the _HexToString function to parse the whole string? I've tried BinaryToString as well (The string doesn't seem to be binary, but the function gives the same results) Test: #include <String.au3> $str = '32347C35397C32312C300032357C3132393033307C382C32343338367C392C317C39392C350033307C317C312C302C302E30302C302C312C352C302C317C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C312C302C302C302C302C302C3000' $str2 = '32347C35397C32312C300032357C3132393033307C382C32343338367C392C317C39392C35' $str3 = '33307C317C312C302C302E30302C302C312C352C302C317C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C302C312C302C302C302C302C302C3000' $hex = _HexToString($str) $hex2 = _HexToString($str2) $hex3 = _HexToString($str3) MsgBox(0,0,$hex) MsgBox(0,0,$hex2) MsgBox(0,0,$hex3) Edited March 31, 2010 by Kickassjoe What goes around comes around... Payback's a bitch.
GerrOrneq Posted March 31, 2010 Posted March 31, 2010 So, when parsing this: ...Hi, The problem appears to be caused by the prescence of '00' in the Hex string that is causing the conversion to abort.'00' is NULL in ASCII and the problem is Not an AutoIt one (I think) but in the way Windows API handles the NULL character conversion.A quick and dirty workaround might be to do some preprocessing on the hex string first and replace all '00' chars with a different set that will Not be appearing in your set of hex strings e.g. 'FF'.(Just be careful that you don't replace '00' where it is made up of a trailing and leading '0' as in '300F'.)I hope this has been of some help to you.DeMo. Quote of the week:"BASIC programmers never die, they GOSUB and don't RETURN." -- UnknownWisdom of the ages: I'd be unstoppable... if not for law enforcement and physics. Marriage, the number 1 cause of divorce. Don't steal... the government hates competition. Irish Government Motto: We’ve got what it takes to take what you’ve got. Birthdays are good for you. Statistics show that the people who have the most live the longest. Failure is not an option. It comes bundled with your Microsoft product.-- Ferenc Mantfeld If you learn from your mistakes, then why ain't I a genius?! -- Anonymous Remember, live every day as if it was your last day! one day you will be right. How is it one careless match can start a forest fire, but it takes a whole box to start a campfire? Sure my system is secure, it just locked up again. I haven't lost my mind; I have a tape back-up somewhere. ~Author Unknown
Kickassjoe Posted March 31, 2010 Author Posted March 31, 2010 FF still gave me a termination of the string, but it also gave me an idea. Why not just change the converter to not put the null character (00 in hex) in the string? It's null anyways... Func _HexToString2($strHex) Local $strChar, $aryHex, $i, $iDec, $Char, $iOne, $iTwo $aryHex = StringSplit($strHex, "") If Mod($aryHex[0], 2) <> 0 Then;if not even strlen, error SetError(1) Return -1 EndIf 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 If $iDec > 0 Then $Char = Chr($iDec) $strChar &= $Char EndIf Next Return $strChar EndFunc ;==>_HexToString2 It converts fine, anything wrong with doing that? What goes around comes around... Payback's a bitch.
trancexx Posted March 31, 2010 Posted March 31, 2010 FF still gave me a termination of the string, but it also gave me an idea. Why not just change the converter to not put the null character (00 in hex) in the string? It's null anyways... Func _HexToString2($strHex) Local $strChar, $aryHex, $i, $iDec, $Char, $iOne, $iTwo $aryHex = StringSplit($strHex, "") If Mod($aryHex[0], 2) <> 0 Then;if not even strlen, error SetError(1) Return -1 EndIf 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 If $iDec > 0 Then $Char = Chr($iDec) $strChar &= $Char EndIf Next Return $strChar EndFunc ;==>_HexToString2 It converts fine, anything wrong with doing that? Nothing except it's kinder garden level. $hex = StringReplace(BinaryToString("0x" & $str), Chr(0), "") ♡♡♡ . eMyvnE
Kickassjoe Posted March 31, 2010 Author Posted March 31, 2010 (edited) Nothing except it's kinder garden level. $hex = StringReplace(BinaryToString("0x" & $str), Chr(0), "") That's exactly what I was looking for <3 Kind of saw that when I was looking at the _HexToString function, but didn't put 2 and 2 together I guess. Thanks Edited March 31, 2010 by Kickassjoe What goes around comes around... Payback's a bitch.
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