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

Function fsencode

tools/python-3.11.9-amd64/Lib/os.py:806–816  ·  view source on GitHub ↗

Encode filename (an os.PathLike, bytes, or str) to the filesystem encoding with 'surrogateescape' error handler, return bytes unchanged. On Windows, use 'strict' error handler if the file system encoding is 'mbcs' (which is the default encoding).

(filename)

Source from the content-addressed store, hash-verified

804 errors = sys.getfilesystemencodeerrors()
805
806 def fsencode(filename):
807 """Encode filename (an os.PathLike, bytes, or str) to the filesystem
808 encoding with 'surrogateescape' error handler, return bytes unchanged.
809 On Windows, use 'strict' error handler if the file system encoding is
810 'mbcs' (which is the default encoding).
811 """
812 filename = fspath(filename) # Does type-checking of `filename`.
813 if isinstance(filename, str):
814 return filename.encode(encoding, errors)
815 else:
816 return filename
817
818 def fsdecode(filename):
819 """Decode filename (an os.PathLike, bytes, or str) from the filesystem

Callers 3

_fwalkFunction · 0.70
_execvpeFunction · 0.70
_iterdirFunction · 0.70

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected