From de72c9d1da8d2d81477f921644db7a55912cddf6 Mon Sep 17 00:00:00 2001 From: "Fan, ZhijuX" Date: Tue, 26 Feb 2019 14:57:44 +0800 Subject: [PATCH] BaseTools:The BOM character is processed when python reads a file When python3 reads an XML file it will parse the file in error if the file has a BOM Cc: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan Reviewed-by: Bob Feng --- BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py index 4294016ae3..00cbc4e55e 100644 --- a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py +++ b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py @@ -17,6 +17,7 @@ # from __future__ import print_function import xml.dom.minidom +import codecs from Common.LongFilePathSupport import OpenLongFilePath as open ## Create a element of XML @@ -211,7 +212,7 @@ def XmlNodeName(Dom): # def XmlParseFile(FileName): try: - XmlFile = open(FileName) + XmlFile = codecs.open(FileName,encoding='utf_8_sig') Dom = xml.dom.minidom.parse(XmlFile) XmlFile.close() return Dom -- 2.39.2