bytes_to_bin

Downloadbytes_to_bin(str)   Returns a string of binary digits converted from the given string of bytes.
/*
**  Usage:
**      bytes_to_bin(str)
**
**  Arguments:
**      str     a string of bytes, eight bits per character
**
**  Returns:
**      a string of binary digits, one bit per character
**
**  GMLscripts.com
*/

{
    var str,bin,p,byte;
    str = argument0;
    bin = "";
    p = string_length(str);
    repeat (p) {
        byte = ord(string_char_at(str,p));
        repeat (8) {
            if (byte & 1) bin = "1" + bin else bin = "0" + bin;
            byte = byte >> 1;
        }
        p -= 1;
    }
    return bin;
}

Click if you've used this script[Please Login]
Projects: 4


comments powered by Disqus