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 <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Fan, ZhijuX 2019-02-26 14:57:44 +08:00 committed by Feng, Bob C
parent 7d180efeaa
commit de72c9d1da
1 changed files with 2 additions and 1 deletions

View File

@ -17,6 +17,7 @@
# #
from __future__ import print_function from __future__ import print_function
import xml.dom.minidom import xml.dom.minidom
import codecs
from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import OpenLongFilePath as open
## Create a element of XML ## Create a element of XML
@ -211,7 +212,7 @@ def XmlNodeName(Dom):
# #
def XmlParseFile(FileName): def XmlParseFile(FileName):
try: try:
XmlFile = open(FileName) XmlFile = codecs.open(FileName,encoding='utf_8_sig')
Dom = xml.dom.minidom.parse(XmlFile) Dom = xml.dom.minidom.parse(XmlFile)
XmlFile.close() XmlFile.close()
return Dom return Dom