(b, encoding='utf-8')
return b
Ensure that b is text in the specified encoding.
Ensure that b is text in the specified encoding.
Ensure that b is text in the specified encoding .
def to_str(b, encoding='utf-8'):
    """Ensure that b is text in the specified encoding."""
    if hasattr(b, 'decode') and not isinstance(b, unicode):
        b = b.decode(encoding)
    return b
def to_str ( b , encoding = 'utf-8' ) : if hasattr ( b , 'decode' ) and not isinstance ( b , unicode ) : b = b . decode ( encoding ) return b