text_to_binary
string text_to_binary ( string text )
This converts given text into 8 bit binary coding (meaning that each
character is represented by 8 bits). The normal ascii representation of the
character is used (so that each character has it's ascii value in the binary
text).
Example 1. Using text_to_binary
{
show_message(text_to_binary("It works!"));
}
Shows message:
010010010111010000100000011101110110111101110010011010110111001100100001
{
var len, i, ascii, retval, binary;
len = string_length(argument0);
retval = "";
for (i = 1; i <= len; i += 1)
{
ascii = ord(string_char_at(argument0, i));
binary = "";
repeat (8)
{
if (ascii & 1)
{
binary = "1" + binary;
}
else
{
binary = "0" + binary;
}
ascii = ascii >> 1;
}
retval += binary;
}
return retval;
}