def to_stdout(string, errors=ERRORS):
    """
    Converts a string to stdout-compatible encoding. This helps
    to avoid getting UnicodeDecodeError exceptions for print
    calls.
    """
    encoded = string.encode(ENCODING, errors)
    decoded = encoded.decode(ENCODING)
    return decoded

    Converts a string to stdout-compatible encoding. This helps
    to avoid getting UnicodeDecodeError exceptions for print
    calls.
    
recipes/Python/578788_No_more_UnicodeDecodeErrors_when/recipe-578788.py