MCPcopy Index your code
hub / github.com/RustPython/RustPython / PyUnicode_DecodeASCII

Function PyUnicode_DecodeASCII

Lib/_pycodecs.py:1148–1167  ·  view source on GitHub ↗
(s, size, errors)

Source from the content-addressed store, hash-verified

1146
1147
1148def PyUnicode_DecodeASCII(s, size, errors):
1149 # /* ASCII is equivalent to the first 128 ordinals in Unicode. */
1150 if size == 1 and ord(s) < 128:
1151 return [chr(ord(s))]
1152 if size == 0:
1153 return [""] # unicode('')
1154 p = []
1155 pos = 0
1156 while pos < len(s):
1157 c = s[pos]
1158 if c < 128:
1159 p += chr(c)
1160 pos += 1
1161 else:
1162 res = unicode_call_errorhandler(
1163 errors, "ascii", "ordinal not in range(128)", s, pos, pos + 1
1164 )
1165 p += res[0]
1166 pos = res[1]
1167 return p
1168
1169
1170def PyUnicode_EncodeASCII(p, size, errors):

Callers 1

ascii_decodeFunction · 0.85

Calls 4

ordFunction · 0.85
chrFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected