From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9004D2194EB7D for ; Tue, 26 Feb 2019 17:32:45 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Feb 2019 17:32:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,417,1544515200"; d="scan'208";a="118056093" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga007.jf.intel.com with ESMTP; 26 Feb 2019 17:32:44 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 26 Feb 2019 17:32:43 -0800 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 26 Feb 2019 17:32:43 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.232]) with mapi id 14.03.0415.000; Wed, 27 Feb 2019 09:32:41 +0800 From: "Feng, Bob C" To: "Fan, ZhijuX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [edk2][PATCH] BaseTools:The BOM character is processed when python reads a file Thread-Index: AdTNoJFvzzip7I7/SsKkCmQNsyv6cQAm7i5g Date: Wed, 27 Feb 2019 01:32:40 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16008FC52@SHSMSX101.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools:The BOM character is processed when python reads a file X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Feb 2019 01:32:45 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Fan, ZhijuX=20 Sent: Tuesday, February 26, 2019 2:58 PM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Feng, Bob C 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 Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan --- 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/Sou= rce/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 =20 ## Create a element of XML @@ -211,7 +212,7 @@ def XmlNodeName(Dom): # def XmlParseFile(FileName): try: - XmlFile =3D open(FileName) + XmlFile =3D codecs.open(FileName,encoding=3D'utf_8_sig') Dom =3D xml.dom.minidom.parse(XmlFile) XmlFile.close() return Dom -- 2.14.1.windows.1