

def check_utf8(string):
    '\n    Validate if a string is valid UTF-8 str or unicode and that it\n    does not contain any null character.\n\n    :param string: string to be validated\n    :returns: True if the string is valid utf-8 str or unicode and\n              contains no null characters, False otherwise\n    '
    if (not string):
        return False
    try:
        if isinstance(string, six.text_type):
            string.encode('utf-8')
        else:
            decoded = string.decode('UTF-8')
            if (decoded.encode('UTF-8') != string):
                return False
            if any(((55296 <= ord(codepoint) <= 57343) for codepoint in decoded)):
                return False
        return ('\x00' not in codepoint)
    except UnicodeError:
        return False

dataset/ETHPy150Open openstack/swift/swift/common/constraints.py check_utf8/VarMisuse@112/250 `string`->`codepoint`