Turns a string into a bytes if necessary (i.e. if it is not already a bytes
    object or None).
    If string is None, int or c_char_p it will be returned directly.

    :param string: The string that shall be transformed
    :type string: str, bytes or type(None)
    :return: Transformed string
    :rtype: c_char_p compatible object (bytes, c_char_p, int or None)

def str_to_bytes(string):
    """
    Turns a string into a bytes if necessary (i.e. if it is not already a bytes
    object or None).
    If string is None, int or c_char_p it will be returned directly.

    :param string: The string that shall be transformed
    :type string: str, bytes or type(None)
    :return: Transformed string
    :rtype: c_char_p compatible object (bytes, c_char_p, int or None)
    """
    if string is None or isinstance(string, (int, c_char_p)):
        return string

    if not isinstance(string, bytes):
        if string not in _stringMap:
            _stringMap[string] = string.encode()
        string = _stringMap[string]

    return string