zprinter.py
def binary_string_to_hex_string(binary_string, debug=False):
    """
    binary_string is an object of type string but representing 1s and 0s
    only. e.g.  binary_string = 00110011001100110011

    If the string is not provided in chunks of 8 (e.g. a byte) then the
    string will be 1-padded from the front. e.g. 11 -> 00000011
    """
    binary_string = binary_string.replace("\x0D", "").replace("\x0A", "")
    len_binstr = len(binary_string)
    remainder = len_binstr % 8
    if remainder != 0:
        binary_string = ("1" * (8 - remainder)) + binary_string
        len_binstr = len(binary_string)

    hex_string = ""
    for n in range(0, len_binstr, 4):
        nibble = binary_string[n:n + 4]
        hex_string += BINARY_TO_HEX[nibble]
        # print("Nibble: ", n, nibble)
        if debug is True:
            print(nibble, end="")

    if debug is True:
        print(" = " + hex_string)

    return(hex_string)

    binary_string is an object of type string but representing 1s and 0s
    only. e.g.  binary_string = 00110011001100110011

    If the string is not provided in chunks of 8 (e.g. a byte) then the
    string will be 1-padded from the front. e.g. 11 -> 00000011
    
binary_string is an object of type string but representing 1s and 0s
only.

If the string is not provided in chunks of 8  then the
string will be 1-padded from the front.
binary_string is an object of type string but representing 1s and 0s only . If the string is not provided in chunks of 8 then the string will be 1 - padded from the front .
def binary_string_to_hex_string(binary_string, debug=False):
    binary_string = binary_string.replace("\x0D", "").replace("\x0A", "")
    len_binstr = len(binary_string)
    remainder = len_binstr % 8
    if remainder != 0:
        binary_string = ("1" * (8 - remainder)) + binary_string
        len_binstr = len(binary_string)
    hex_string = ""
    for n in range(0, len_binstr, 4):
        nibble = binary_string[n:n + 4]
        hex_string += BINARY_TO_HEX[nibble]
        if debug is True:
            print(nibble, end="")
    if debug is True:
        print(" = " + hex_string)
    return(hex_string)
def binary_string_to_hex_string ( binary_string , debug = False ) : binary_string = binary_string . replace ( "\x0D" , "" ) . replace ( "\x0A" , "" ) len_binstr = len ( binary_string ) remainder = len_binstr % 8 if remainder != 0 : binary_string = ( "1" * ( 8 - remainder ) ) + binary_string len_binstr = len ( binary_string ) hex_string = "" for n in range ( 0 , len_binstr , 4 ) : nibble = binary_string [ n : n + 4 ] hex_string += BINARY_TO_HEX [ nibble ] if debug is True : print ( nibble , end = "" ) if debug is True : print ( " = " + hex_string ) return ( hex_string )
binary_string is an object of type string but representing 1s and 0s
only.
binary_string is an object of type string but representing 1s and 0s only .
"""
    binary_string is an object of type string but representing 1s and 0s
    only. e.g.  binary_string = 00110011001100110011

    If the string is not provided in chunks of 8 (e.g. a byte) then the
    string will be 1-padded from the front. e.g. 11 -> 00000011
    """ # print("Nibble: ", n, nibble)
binary_string
debug