def __subfields(t, d):
    """ Unpack subfield data into tuples. """

    # Remove extra trailing subfield delimiters, if neccessary, before
    # splitting into subfields
    subf = d.rstrip(b"\x1f").split(b"\x1f")

    # No subfields means it's a control field, with no indicators and
    # no subfield code
    if len(subf) == 1:
        return (t, None, None, (None, d.decode()))

    return (t, chr(subf[0][0]), chr(subf[0][1])) + \
        tuple([(chr(s[0]), s[1:].decode()) for s in subf[1:]])