]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/UniClassObject.py
Revert BaseTools: PYTHON3 migration
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / UniClassObject.py
index 1c86be4429adfc91e7dc820d84e62ee2ed62f31a..384f31b165de08222f36e8f5330549ec7182da7e 100644 (file)
@@ -16,6 +16,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os, codecs, re\r
 import distutils.util\r
 import Common.EdkLogger as EdkLogger\r
@@ -45,6 +46,18 @@ BACK_SLASH_PLACEHOLDER = u'\u0006'
 \r
 gIncludePattern = re.compile("^#include +[\"<]+([^\"< >]+)[>\"]+$", re.MULTILINE | re.UNICODE)\r
 \r
+## Convert a python unicode string to a normal string\r
+#\r
+# Convert a python unicode string to a normal string\r
+# UniToStr(u'I am a string') is 'I am a string'\r
+#\r
+# @param Uni:  The python unicode string\r
+#\r
+# @retval:     The formatted normal string\r
+#\r
+def UniToStr(Uni):\r
+    return repr(Uni)[2:-1]\r
+\r
 ## Convert a unicode string to a Hex list\r
 #\r
 # Convert a unicode string to a Hex list\r
@@ -426,7 +439,7 @@ class UniFileClassObject(object):
                 if EndPos != -1 and EndPos - StartPos == 6 :\r
                     if g4HexChar.match(Line[StartPos + 2 : EndPos], re.UNICODE):\r
                         EndStr = Line[EndPos: ]\r
-                        UniStr = Line[StartPos + 2: EndPos]\r
+                        UniStr = ('\u' + (Line[StartPos + 2 : EndPos])).decode('unicode_escape')\r
                         if EndStr.startswith(u'\\x') and len(EndStr) >= 7:\r
                             if EndStr[6] == u'\\' and g4HexChar.match(EndStr[2 : 6], re.UNICODE):\r
                                 Line = Line[0 : StartPos] + UniStr + EndStr\r