MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / stn

Function stn

tools/python-3.11.9-amd64/Lib/tarfile.py:160–166  ·  view source on GitHub ↗

Convert a string to a null-terminated bytes object.

(s, length, encoding, errors)

Source from the content-addressed store, hash-verified

158#---------------------------------------------------------
159
160def stn(s, length, encoding, errors):
161 """Convert a string to a null-terminated bytes object.
162 """
163 if s is None:
164 raise ValueError("metadata cannot contain None")
165 s = s.encode(encoding, errors)
166 return s[:length] + (length - len(s)) * NUL
167
168def nts(s, encoding, errors):
169 """Convert a null-terminated bytes object to a string.

Callers 1

_create_headerMethod · 0.85

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected