Jump to content

new Binary stuff


Recommended Posts

i'm a bit stuck here:

$test = Binary("Hello")
ConsoleWrite($test & @LF) ; Prints 0x48656C6C6F
ConsoleWrite(String($test) & @LF) ; Prints 0x48656C6C6F too, why ?

$struct = DllStructCreate("byte Buff[5]")
$struct.Buff = $test
ConsoleWrite($struct.Buff & @LF) ; ok 0x48656C6C6F again...
$struct2 = DllStructCreate("char zBuff[6]",DllStructGetPtr($struct))
ConsoleWrite($struct2.zBuff & @LF) ; Prints Hello" but why "
ConsoleWrite(StringLeft($struct2.zBuff,BinaryLen($test)) & @LF) ; Finally prints Hello :)

any idea how to convert a Binary back into a string?

maybe a bit easier than i did it :shocked:

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

; Test convert Binary to String
#include <string.au3>

$HexString = _StringToHex ("This is a test, it is only a test...")
ConsoleWrite("Hex string:  " & $HexString & @LF)

$String = _HexToString ($HexString)
ConsoleWrite("Text string:  " & $String & @LF)

Dog ate your help file...? :shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Sorry, missed a step...

#include <string.au3>

$Bin = Binary ("Hello")
ConsoleWrite("$Bin = " & $Bin & @LF)
$Hex = Hex($Bin)
ConsoleWrite("$Hex = " & $Hex & @LF)
$Text = _HexToString($Hex)
ConsoleWrite("$Text = " & $Text & @LF)

Doggy wants his bone! :shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 1 month later...

i'm a bit stuck here:

$test = Binary("Hello")
ConsoleWrite($test & @LF) ; Prints 0x48656C6C6F
ConsoleWrite(String($test) & @LF) ; Prints 0x48656C6C6F too, why ?

$struct = DllStructCreate("byte Buff[5]")
$struct.Buff = $test
ConsoleWrite($struct.Buff & @LF) ; ok 0x48656C6C6F again...
$struct2 = DllStructCreate("char zBuff[6]",DllStructGetPtr($struct))
ConsoleWrite($struct2.zBuff & @LF) ; Prints Hello" but why "
ConsoleWrite(StringLeft($struct2.zBuff,BinaryLen($test)) & @LF) ; Finally prints Hello :)

any idea how to convert a Binary back into a string?

maybe a bit easier than i did it :)

Just upgraded to AutoIt v3.2.4.4 and now I'm stuck too! The CoProc functions do not seem to work with 3.2.4.4. Obviously, BinaryString has to be changed to Binary, but the String function doesn't seem to work as expected as noted in this thread.

I would hope we don't have to use _HexToString on the received parameter...(I can't get that to work either).

Is anyone else experiencing this problem with 3.2.4.4?

Thanks,

Paul

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...