Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update encoding to use locale based detection when parsing logs #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions edk2basetools/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from edk2basetools.Common.BuildToolError import *
from edk2basetools.Common.DataType import *
import edk2basetools.Common.EdkLogger as EdkLogger
import locale

from edk2basetools.Workspace.WorkspaceDatabase import BuildDB

Expand Down Expand Up @@ -181,14 +182,16 @@ def NormFile(FilePath, Workspace):
# @param ExitFlag The flag used to indicate stopping reading
#
def ReadMessage(From, To, ExitFlag,MemTo=None):
(_, encoding) = locale.getdefaultlocale()
while True:
# read one line a time
Line = From.readline()
# empty string means "end"
if Line is not None and Line != b"":
LineStr = Line.rstrip().decode(encoding='utf-8', errors='ignore')
LineStr = Line.rstrip().decode(encoding, errors='ignore')
if MemTo is not None:
if "Note: including file:" == LineStr.lstrip()[:21]:
if "Note: including file:" == LineStr.lstrip()[:21] or\
"注意: 包含文件: " == LineStr.lstrip()[:10]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this?

Do we need this in all supported languages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the Chinese counterpart of "Note: including file" lines from compiler. It will spew many lines for each c file it built. I think that's why it was there in the first place. Do you know by chance where to look up this information, other than testing installation on all locales? (I think this is specific to CL)

MemTo.append(LineStr)
else:
To(LineStr)
Expand Down