MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / remove_null_bytes

Function remove_null_bytes

src/textcode/analysis.py:287–295  ·  view source on GitHub ↗

Return a string replacing by a space all null bytes. There are some rare cases where we can have binary strings that are not caught early when detecting a file type, but only late at the line level. This help catch most of these cases.

(s)

Source from the content-addressed store, hash-verified

285
286
287def remove_null_bytes(s):
288 """
289 Return a string replacing by a space all null bytes.
290
291 There are some rare cases where we can have binary strings that are not
292 caught early when detecting a file type, but only late at the line level.
293 This help catch most of these cases.
294 """
295 return s.replace('\x00', ' ')
296
297
298def remove_verbatim_cr_lf_tab_chars(s):

Callers 1

as_unicodeFunction · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected