'Helper for the built-in unicode function.'

def __unicode__(self):

    uchunks = []
    lastcs = None
    for (s, charset) in self._chunks:
        nextcs = charset
        if uchunks:
            if (lastcs not in (None, 'us-ascii')):
                if (nextcs in (None, 'us-ascii')):
                    uchunks.append(USPACE)
                    nextcs = None
            elif (nextcs not in (None, 'us-ascii')):
                uchunks.append(USPACE)
        lastcs = nextcs
        uchunks.append(unicode(s, str(charset)))
    return UEMPTYSTRING.join(uchunks)
