summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/UPT/Library/UniClassObject.py
diff options
context:
space:
mode:
authorHess Chen <hesheng.chen@intel.com>2015-07-08 05:43:22 +0000
committerhchen30 <hchen30@Edk2>2015-07-08 05:43:22 +0000
commitfe90f4836a37fc7210aa9fd351b8ca786ee9bf23 (patch)
tree611a67a293c8fd93c81291bafe8a0c8a63220adc /BaseTools/Source/Python/UPT/Library/UniClassObject.py
parentc581e5037dca6e1446972aed194f13c9cdd0b01b (diff)
downloadedk2-platforms-fe90f4836a37fc7210aa9fd351b8ca786ee9bf23.tar.xz
BaseTools/Upt: Add a BOM check for UNI file and fix some help message error
Add a BOM check for UNI file and fix some help message error Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: YangX Li <yangx.li@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17876 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/UPT/Library/UniClassObject.py')
-rw-r--r--BaseTools/Source/Python/UPT/Library/UniClassObject.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
index 332ae273c7..c57bfdf57d 100644
--- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py
+++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
@@ -27,6 +27,7 @@ from Library.String import GetLineNo
from Library.Misc import PathClass
from Library.Misc import GetCharIndexOutStr
from Library import DataType as DT
+from Library.ParserValidate import CheckUTF16FileHeader
##
# Static definitions
@@ -136,6 +137,8 @@ def ConvertSpecialUnicodes(Uni):
# @retval LangName: Valid lanugage code in RFC 1766 format or None
#
def GetLanguageCode1766(LangName, File=None):
+ return LangName
+
length = len(LangName)
if length == 2:
if LangName.isalpha():
@@ -424,6 +427,13 @@ class UniFileClassObject(object):
ToolError.FILE_NOT_FOUND,
ExtraData=File.Path)
+ #
+ # 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)
+
try:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').readlines()
except UnicodeError:
@@ -570,11 +580,13 @@ class UniFileClassObject(object):
StringEntryExistsFlag = 1
if not Line.endswith('"'):
- EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
+ EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
+ ExtraData='''The line %s misses '"' at the end of it in file %s'''
+ % (LineCount, File.Path))
elif Line.startswith(u'#language'):
if StringEntryExistsFlag == 2:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
- Message=ST.ERR_UNIPARSE_LINEFEED_UP_EXIST % Line, ExtraData=File.Path)
+ Message=ST.ERR_UNI_MISS_STRING_ENTRY % Line, ExtraData=File.Path)
StringEntryExistsFlag = 0
else:
StringEntryExistsFlag = 0