MCPcopy Create free account
hub / github.com/bugy/script-server / try_encoded_read

Function try_encoded_read

src/utils/file_utils.py:74–84  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

72
73
74def try_encoded_read(path):
75 encodings = ['utf_8', 'cp1251', 'iso-8859-1', 'koi8_r', 'cp1252', 'cp1250', 'latin1', 'utf_32']
76
77 for encoding in encodings:
78 try:
79 with open(path, 'r', encoding=encoding) as f:
80 return f.read()
81 except UnicodeDecodeError:
82 pass
83
84 return None
85
86
87def write_file(filename, content, byte_content=False):

Callers 1

read_fileFunction · 0.85

Calls 1

readMethod · 0.80

Tested by

no test coverage detected