import string


def format_character(char):
    """Returns the C-formatting of the character"""
    if \
        char in string.ascii_letters \
        or char in string.digits \
        or char in [
                '_', '.', ':', ';', ' ', '!', '?', '+', '-', '/', '=', '<',
                '>', '$', '(', ')', '@', '~', '`', '|', '#', '[', ']', '{',
                '}', '&', '*', '^', '%']:
        return char
    elif char in ['"', '\'', '\\']:
        return '\\{0}'.format(char)
    elif char == '\n':
        return '\\n'
    elif char == '\r':
        return '\\r'
    elif char == '\t':
        return '\\t'
    else:
        return '\\x{:02x}'.format(ord(char))