def charmap_decode(space, string, errors="strict", w_mapping=None): if errors is None: errors = 'strict' if len(string) == 0: return space.newtuple([space.wrap(u''), space.wrap(0)]) if space.is_none(w_mapping): mapping = None else: mapping = Charmap_Decode(space, w_mapping) final = True state = space.fromcache(CodecState) result, consumed = runicode.str_decode_charmap( string, len(string), errors, final, state.decode_error_handler, mapping) return space.newtuple([space.wrap(result), space.wrap(consumed)])
def charmap_decode(space, string, errors="strict", w_mapping=None): if errors is None: errors = 'strict' if len(string) == 0: return space.newtuple([space.newunicode(u''), space.newint(0)]) if space.is_none(w_mapping): mapping = None else: mapping = Charmap_Decode(space, w_mapping) final = True state = space.fromcache(CodecState) result, consumed = runicode.str_decode_charmap( string, len(string), errors, final, state.decode_error_handler, mapping) return space.newtuple([space.newunicode(result), space.newint(consumed)])