* Move pyopen with encoding to utils. (#19377)
and modify all importing library to use pyopen with encoding. with this change, DXF OCA AirfoilDAT with multibyte sequence always read as utf-8.
This commit is contained in:
@@ -43,6 +43,7 @@ import FreeCAD as App
|
||||
from draftutils import params
|
||||
from draftutils.messages import _wrn, _err, _log
|
||||
from draftutils.translate import translate
|
||||
from builtins import open
|
||||
|
||||
# TODO: move the functions that require the graphical interface
|
||||
# This module should not import any graphical commands; those should be
|
||||
@@ -1197,4 +1198,10 @@ def use_instead(function, version=""):
|
||||
else:
|
||||
_wrn(translate("draft", "This function will be deprecated. Please use '{}'.") .format(function))
|
||||
|
||||
|
||||
def pyopen(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None):
|
||||
if encoding is None:
|
||||
encoding = 'utf-8'
|
||||
return open(file, mode, buffering, encoding, errors, newline, closefd, opener)
|
||||
|
||||
## @}
|
||||
|
||||
Reference in New Issue
Block a user