public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools:The BOM character is processed when python reads a file
@ 2019-02-26  6:57 Fan, ZhijuX
  2019-02-27  1:32 ` Feng, Bob C
  0 siblings, 1 reply; 2+ messages in thread
From: Fan, ZhijuX @ 2019-02-26  6:57 UTC (permalink / raw)
  To: edk2-devel@lists.01.org; +Cc: Gao, Liming, Feng, Bob C

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>
---
 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.14.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] BaseTools:The BOM character is processed when python reads a file
  2019-02-26  6:57 [PATCH] BaseTools:The BOM character is processed when python reads a file Fan, ZhijuX
@ 2019-02-27  1:32 ` Feng, Bob C
  0 siblings, 0 replies; 2+ messages in thread
From: Feng, Bob C @ 2019-02-27  1:32 UTC (permalink / raw)
  To: Fan, ZhijuX, edk2-devel@lists.01.org; +Cc: Gao, Liming

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

-----Original Message-----
From: Fan, ZhijuX 
Sent: Tuesday, February 26, 2019 2:58 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Feng, Bob C <bob.c.feng@intel.com>
Subject: [edk2][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 <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>
---
 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.14.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-27  1:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-26  6:57 [PATCH] BaseTools:The BOM character is processed when python reads a file Fan, ZhijuX
2019-02-27  1:32 ` Feng, Bob C

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox