def _transcode(s, encoding):
    """Common implementation for interpret_text and interpret_simpletext."""
    u = s.decode(encoding)
    if encoding == 'UTF-8':
        return s
    else:
        return u.encode('utf-8')
