http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/util.c?id=v3.17#n313.

    Positional arguments:
    data -- bytearray data to read.

    Returns:
    String.

def get_ssid(_, data):
    """http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/util.c?id=v3.17#n313.

    Positional arguments:
    data -- bytearray data to read.

    Returns:
    String.
    """
    converted = list()
    for i in range(len(data)):
        try:
            c = unichr(data[i])
        except NameError:
            c = chr(data[i])
        if unicodedata.category(c) != 'Cc' and c not in (' ', '\\'):
            converted.append(c)
        elif c == '\0':
            converted.append(c)
        elif c == ' ' and i not in (0, len(data)):
            converted.append(' ')
        else:
            converted.append('\\{0:02x}'.format(data[i]))
    return ''.join(converted)