Core Function BinaryFromStr

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> BinaryFromStr( <string> ) </pre> === Description === Returns a new binary variable created from a strings raw bytes === Parameters === ==== string ==== The string to ...")
 
(Example)
Line 22: Line 22:
  
 
=== Example ===
 
=== Example ===
 +
 +
 +
ASCII Example
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
$binary = Pack("z0iii", "Hello World!", 100, 200, 300);
+
$binary = Pack("A*", "Hello World!");
echo "First binary variable printed BELOW\n";
+
printr($binary);
+
echo "First binary variable printed ABOVE\n";
+
 
$binStr = BinaryToStr($binary);
 
$binStr = BinaryToStr($binary);
 
echo "String Content: $binStr\n";
 
echo "String Content: $binStr\n";
echo "Second binary variable printed BELOW\n";
+
// Prints:
printr(BinaryFromStr($binStr));
+
// String Content: Hello World!
echo "Second binary variable printed ABOVE\n";
+
/*
+
Prints:
+
First binary variable printed BELOW
+
{BINARY:24}
+
{
+
        [0] => 72
+
        [1] => 101
+
        [2] => 108
+
        [3] => 108
+
        [4] => 111
+
        [5] => 32
+
        [6] => 87
+
        [7] => 111
+
        [8] => 114
+
        [9] => 108
+
        [10] => 100
+
        [11] => 33
+
        [12] => 100
+
        [13] => 0
+
        [14] => 0
+
        [15] => 0
+
        [16] => 200
+
        [17] => 0
+
        [18] => 0
+
        [19] => 0
+
        [20] => 44
+
        [21] => 1
+
        [22] => 0
+
        [23] => 0
+
}
+
First binary variable printed ABOVE
+
String Content: Hello World!d  È  ,☺
+
Second binary variable printed BELOW
+
{BINARY:24}
+
{
+
        [0] => 72
+
        [1] => 101
+
        [2] => 108
+
        [3] => 108
+
        [4] => 111
+
        [5] => 32
+
        [6] => 87
+
        [7] => 111
+
        [8] => 114
+
        [9] => 108
+
        [10] => 100
+
        [11] => 33
+
        [12] => 100
+
        [13] => 0
+
        [14] => 0
+
        [15] => 0
+
        [16] => 200
+
        [17] => 0
+
        [18] => 0
+
        [19] => 0
+
        [20] => 44
+
        [21] => 1
+
        [22] => 0
+
        [23] => 0
+
}
+
Second binary variable printed ABOVE
+
*/
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 15:31, 26 September 2013

BinaryFromStr( <string> )

Contents

Description

Returns a new binary variable created from a strings raw bytes

Parameters

string

The string to use.

Return Value

Returns a new binary variable created from a strings raw bytes

Remarks

None.

Example

ASCII Example

$binary = Pack("A*", "Hello World!");
$binStr = BinaryToStr($binary);
echo "String Content: $binStr\n";
// Prints:
// String Content: Hello World!
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox