Core Function BinaryHex

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
(Example)
Line 26: Line 26:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
$binary = BinaryHex("48656c6c6f20576f726c6421")
+
$binary = BinaryHex("48656c6c6f20576f726c6421");
println( "Binary HEX: '" . BinaryStr($binary, ",") . "'" )
+
println( "Binary HEX: '" . BinaryStr($binary, ",") . "'" );
println("The binary size is: " . UBound($binary) )
+
println("The binary size is: " . BinaryLen($binary) );
For $i In $binary
+
Foreach ($binary as $i)
println( "Byte: " . $i . " | Hex: " . Hex($i) . " | Char: " . Chr($i) )
+
{
Next
+
println( "Byte: " . $i . " | Hex: " . Hex($i) . " | Char: " . Chr($i) );
$String = Unpack("z0", $binary)
+
}
println("Full string: " . $String)
+
$String = Unpack("z0", $binary);
 +
println("Full string: " . $String);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 17:21, 19 November 2011

BinaryHex( <expression> )

Contents

Description

Create a binary array from a hex string.

Parameters

expression

A string of hex to convert into a binary variable.

Return Value

Success: Returns the binary variable.

Failure: Returns 0.

Remarks

The string must contain only the hex chars nothing else not even 0x or spaces.

Example

$binary = BinaryHex("48656c6c6f20576f726c6421");
println( "Binary HEX: '" . BinaryStr($binary, ",") . "'" );
println("The binary size is: " . BinaryLen($binary) );
Foreach ($binary as $i)
{
	println( "Byte: " . $i . " | Hex: " . Hex($i) . " | Char: " . Chr($i) );
}
$String = Unpack("z0", $binary);
println("Full string: " . $String);
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox