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

Function _byte_offset_to_character_offset

Lib/traceback.py:794–796  ·  view source on GitHub ↗
(str, offset)

Source from the content-addressed store, hash-verified

792
793
794def _byte_offset_to_character_offset(str, offset):
795 as_utf8 = str.encode('utf-8')
796 return len(as_utf8[:offset].decode("utf-8", errors="replace"))
797
798
799_Anchors = collections.namedtuple(

Callers 2

format_frame_summaryMethod · 0.85
normalizeFunction · 0.85

Calls 3

lenFunction · 0.85
encodeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected