MCPcopy Index your code
hub / github.com/nodejs/node / _DetectInputEncoding

Method _DetectInputEncoding

tools/gyp/pylib/gyp/mac_tool.py:155–168  ·  view source on GitHub ↗

Reads the first few bytes from file_name and tries to guess the text encoding. Returns None as a guess if it can't detect it.

(self, file_name)

Source from the content-addressed store, hash-verified

153 fp.write(s.decode(input_code).encode("UTF-16"))
154
155 def _DetectInputEncoding(self, file_name):
156 """Reads the first few bytes from file_name and tries to guess the text
157 encoding. Returns None as a guess if it can't detect it."""
158 with open(file_name, "rb") as fp:
159 try:
160 header = fp.read(3)
161 except Exception:
162 return None
163 if header.startswith((b"\xfe\xff", b"\xff\xfe")):
164 return "UTF-16"
165 elif header.startswith(b"\xef\xbb\xbf"):
166 return "UTF-8"
167 else:
168 return None
169
170 def ExecCopyInfoPlist(self, source, dest, convert_to_binary, *keys):
171 """Copies the |source| Info.plist to the destination directory |dest|."""

Callers 1

_CopyStringsFileMethod · 0.95

Calls 2

openFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected