mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 10:37:13 +02:00
Fall back to latin-1 encoding when failed with UTF-8 while parsing manifest
This commit is contained in:
@ -61,8 +61,14 @@ class ManifestFileType(object):
|
|||||||
class ManifestParserFactory(object):
|
class ManifestParserFactory(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read_manifest_contents(path):
|
def read_manifest_contents(path):
|
||||||
with io.open(path, encoding="utf-8") as fp:
|
last_err = None
|
||||||
return fp.read()
|
for encoding in ("utf-8", "latin-1"):
|
||||||
|
try:
|
||||||
|
with io.open(path, encoding=encoding) as fp:
|
||||||
|
return fp.read()
|
||||||
|
except UnicodeDecodeError as e:
|
||||||
|
last_err = e
|
||||||
|
raise last_err
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new_from_file(cls, path, remote_url=False):
|
def new_from_file(cls, path, remote_url=False):
|
||||||
|
Reference in New Issue
Block a user