summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/UPT
diff options
context:
space:
mode:
authorHess Chen <hesheng.chen@intel.com>2016-04-22 13:23:38 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2016-04-26 12:02:02 +0800
commit4a21fb3b67a0ef1655b43e9368b6b697bbf327af (patch)
treec1c800c5e63a35677d3530bc10c99e8463eb373d /BaseTools/Source/Python/UPT
parentb739e14d7fbfce5b58411bf214a33bbcb7cf4102 (diff)
downloadedk2-4a21fb3b67a0ef1655b43e9368b6b697bbf327af.tar.gz
edk2-4a21fb3b67a0ef1655b43e9368b6b697bbf327af.tar.bz2
edk2-4a21fb3b67a0ef1655b43e9368b6b697bbf327af.zip
BaseTools/UPT: UPT to Support UTF-8
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/UPT')
-rw-r--r--BaseTools/Source/Python/UPT/Library/UniClassObject.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
index c57bfdf57d..1e73d3e9a8 100644
--- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py
+++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
@@ -1,7 +1,7 @@
## @file
# Collect all defined strings in multiple uni files.
#
-# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -328,6 +328,8 @@ class UniFileClassObject(object):
Lang = distutils.util.split_quoted((Line.split(u"//")[0]))
if len(Lang) != 3:
try:
+ FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').read()
+ except UnicodeError, Xstr:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').read()
except UnicodeError, Xstr:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').read()
@@ -430,11 +432,13 @@ class UniFileClassObject(object):
#
# Check file header of the Uni file
#
- if not CheckUTF16FileHeader(File.Path):
- EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
- ExtraData='The file %s is either invalid UTF-16LE or it is missing the BOM.' % File.Path)
+# if not CheckUTF16FileHeader(File.Path):
+# EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
+# ExtraData='The file %s is either invalid UTF-16LE or it is missing the BOM.' % File.Path)
try:
+ FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').read()
+ except UnicodeError, Xstr:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').readlines()
except UnicodeError:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').readlines()
@@ -1046,6 +1050,8 @@ class UniFileClassObject(object):
ToolError.FILE_NOT_FOUND,
ExtraData=FilaPath)
try:
+ FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_8').read()
+ except UnicodeError, Xstr:
FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_16').readlines()
except UnicodeError:
FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_16_le').readlines()