from Library.Misc import PathClass\r
from Library.Misc import GetCharIndexOutStr\r
from Library import DataType as DT\r
+from Library.ParserValidate import CheckUTF16FileHeader\r
\r
##\r
# Static definitions\r
# @retval LangName: Valid lanugage code in RFC 1766 format or None\r
#\r
def GetLanguageCode1766(LangName, File=None):\r
+ return LangName\r
+\r
length = len(LangName)\r
if length == 2:\r
if LangName.isalpha():\r
ToolError.FILE_NOT_FOUND,\r
ExtraData=File.Path)\r
\r
+ #\r
+ # Check file header of the Uni file\r
+ #\r
+ if not CheckUTF16FileHeader(File.Path):\r
+ EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,\r
+ ExtraData='The file %s is either invalid UTF-16LE or it is missing the BOM.' % File.Path)\r
+\r
try:\r
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').readlines()\r
except UnicodeError:\r
\r
StringEntryExistsFlag = 1\r
if not Line.endswith('"'):\r
- EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)\r
+ EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,\r
+ ExtraData='''The line %s misses '"' at the end of it in file %s'''\r
+ % (LineCount, File.Path))\r
elif Line.startswith(u'#language'):\r
if StringEntryExistsFlag == 2:\r
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \r
- Message=ST.ERR_UNIPARSE_LINEFEED_UP_EXIST % Line, ExtraData=File.Path)\r
+ Message=ST.ERR_UNI_MISS_STRING_ENTRY % Line, ExtraData=File.Path)\r
StringEntryExistsFlag = 0\r
else:\r
StringEntryExistsFlag = 0\r