(exc)
return c2, exc.start + 1
Replace only one symbol at a time.

    Builtin .decode('xxx', 'replace') replaces several symbols
    together, which is unsafe.
Replace only one symbol at a time.
Replace only one symbol at a time .
def safe_replace(exc):
    """Replace only one symbol at a time.

    Builtin .decode('xxx', 'replace') replaces several symbols
    together, which is unsafe.
    """
    if not isinstance(exc, UnicodeDecodeError):
        raise exc
    c2 = REPLACEMENT_SYMBOL

    # we could assume latin1
    if 0:
        c1 = exc.object[exc.start]
        c2 = unichr(ord(c1))

    return c2, exc.start + 1
def safe_replace ( exc ) : if not isinstance ( exc , UnicodeDecodeError ) : raise exc c2 = REPLACEMENT_SYMBOL # we could assume latin1 if 0 : c1 = exc . object [ exc . start ] c2 = unichr ( ord ( c1 ) ) return c2 , exc . start + 1