summaryrefslogtreecommitdiff
path: root/BaseTools
diff options
context:
space:
mode:
authorYonghong Zhu <yonghong.zhu@intel.com>2016-05-03 15:44:27 +0800
committerHao Wu <hao.a.wu@intel.com>2016-07-13 09:32:49 +0800
commitb81734528981c2104c14fbb91285f7449651f718 (patch)
tree830a0a6191a61e257d40333ed04a98d7980903f4 /BaseTools
parent177b3abbdaa1247503e1eb3355e6816dbfe042a9 (diff)
downloadedk2-platforms-b81734528981c2104c14fbb91285f7449651f718.tar.xz
BaseTools: Support \x####\ in UNI files to specify non-ascii characters
UNI spec updated to allow using \x####\ to specify non-ascii characters, # is a hex digit. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> (cherry picked from commit 314e2fb1752679392e9fe386564ef04d99680a93)
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/Python/AutoGen/UniClassObject.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py
index a01381be5e..d28fd3a1ea 100644
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
@@ -4,7 +4,7 @@
#
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.<BR>
#
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 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 distribution. The full text of the license may be found at
@@ -432,9 +432,19 @@ class UniFileClassObject(object):
Line = Line.replace(u"\\'", u"'")
Line = Line.replace(BACK_SLASH_PLACEHOLDER, u'\\')
-# if Line.find(u'\\x'):
-# hex = Line[Line.find(u'\\x') + 2 : Line.find(u'\\x') + 6]
-# hex = "u'\\u" + hex + "'"
+ StartPos = Line.find(u'\\x')
+ while (StartPos != -1):
+ EndPos = Line.find(u'\\', StartPos + 1, StartPos + 7)
+ if EndPos != -1 and EndPos - StartPos == 6 :
+ if re.match('[a-fA-F0-9]{4}', Line[StartPos + 2 : EndPos], re.UNICODE):
+ EndStr = Line[EndPos: ]
+ UniStr = ('\u' + (Line[StartPos + 2 : EndPos])).decode('unicode_escape')
+ if EndStr.startswith(u'\\x') and len(EndStr) >= 7:
+ if EndStr[6] == u'\\' and re.match('[a-fA-F0-9]{4}', EndStr[2 : 6], re.UNICODE):
+ Line = Line[0 : StartPos] + UniStr + EndStr
+ else:
+ Line = Line[0 : StartPos] + UniStr + EndStr[1:]
+ StartPos = Line.find(u'\\x', StartPos)
IncList = gIncludePattern.findall(Line)
if len(IncList) == 1: