From: Fan, ZhijuX Date: Tue, 26 Feb 2019 06:57:44 +0000 (+0800) Subject: BaseTools:The BOM character is processed when python reads a file X-Git-Tag: edk2-stable201903~23 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=de72c9d1da8d2d81477f921644db7a55912cddf6 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 --- 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