Core Function BinaryLen

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
(Example)
Line 33: Line 33:
 
println( "Byte: " . $i . " | Hex: " . Hex($i) . " | Char: " . Chr($i) );
 
println( "Byte: " . $i . " | Hex: " . Hex($i) . " | Char: " . Chr($i) );
 
}
 
}
$String = Unpack("z0", $binary);
+
$String = Unpack("A*", $binary, 3);
 
println("Full string: " . $String);
 
println("Full string: " . $String);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 14:21, 27 September 2013

BinaryLen( <binary-array> )

Contents

Description

Returns the number of bytes in a binary variable.

Parameters

binary-array

The binary variable to evaluate.

Return Value

Success: Returns the length of the binary data in bytes.

Failure: Returns -1.

Remarks

UBound works just as good for this.

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("A*", $binary, 3);
println("Full string: " . $String);
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox