(base, extended, errors)
return base
3.2 Insertion unsort coding
3.2 Insertion unsort coding
3 . 2 Insertion unsort coding
def insertion_sort(base, extended, errors):
    """3.2 Insertion unsort coding"""
    char = 0x80
    pos = -1
    bias = 72
    extpos = 0
    while extpos < len(extended):
        newpos, delta = decode_generalized_number(extended, extpos,
                                                  bias, errors)
        if delta is None:
            # There was an error in decoding. We can't continue because
            # synchronization is lost.
            return base
        pos += delta+1
        char += pos // (len(base) + 1)
        if char > 0x10FFFF:
            if errors == "strict":
                raise UnicodeError("Invalid character U+%x" % char)
            char = ord('?')
        pos = pos % (len(base) + 1)
        base = base[:pos] + chr(char) + base[pos:]
        bias = adapt(delta, (extpos == 0), len(base))
        extpos = newpos
    return base
def insertion_sort ( base , extended , errors ) : char = 0x80 pos = - 1 bias = 72 extpos = 0 while extpos < len ( extended ) : newpos , delta = decode_generalized_number ( extended , extpos , bias , errors ) if delta is None : # There was an error in decoding. We can't continue because # synchronization is lost. return base pos += delta + 1 char += pos // ( len ( base ) + 1 ) if char > 0x10FFFF : if errors == "strict" : raise UnicodeError ( "Invalid character U+%x" % char ) char = ord ( '?' ) pos = pos % ( len ( base ) + 1 ) base = base [ : pos ] + chr ( char ) + base [ pos : ] bias = adapt ( delta , ( extpos == 0 ) , len ( base ) ) extpos = newpos return base