* 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:
Mino-Tsuzuku
2025-02-04 19:33:43 +09:00
committed by GitHub
parent 2225e7c32f
commit 0ce232b38a
5 changed files with 22 additions and 11 deletions

View File

@@ -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)
## @}