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)
| 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|.""" |
no test coverage detected