def tostr_impl(s): n = len(s) is_ascii = s.isascii() result = unicode._empty_string(unicode.PY_UNICODE_1BYTE_KIND, n, is_ascii) for i in range(n): code = get_code(s, i) unicode._set_code_point(result, i, code) return result
def str_impl(s): n = len(s) kind = s._get_kind() is_ascii = kind == 1 and s.isascii() result = unicode._empty_string(kind, n, is_ascii) for i in range(n): code = get_code(s, i) unicode._set_code_point(result, i, code) return result
def charseq_to_str(x, max_l=100): l = charseq_len(x) if (l == 0): return "" else: s = NULL * (l + 1) for i in range(l): _set_code_point(s, i, x[i]) return s[:l]