Skip to content

Conversation

@etnperlong
Copy link

Description

This PR fixes a UnicodeEncodeError that occurs when processing firmware dumps containing non-ASCII characters in build properties, especially on systems where the default locale encoding is not UTF-8.

Problem

When processing certain Chinese ROMs (e.g., TB375FC_CN), the tool crashes during the proprietary files list generation or build properties dumping phase:

Traceback (most recent call last):

  File "aospdtgen/utils/format_props.py", line 52, in dump_partition_build_prop
    f.write(f"{prop}={build_prop.get_prop(prop)}\n")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 32-33: ordinal not in range(128)

This is because the file is opened using the environment's default encoding (often ASCII), which cannot handle the Unicode characters present in the build properties.

Solution

Ensured that all text-based file writing operations explicitly use UTF-8 encoding:

Verification

The fix has been verified to correctly process ROMs that previously caused the crash.

Specify explicitly `encoding="utf-8"` when writing files to prevent `UnicodeEncodeError` on systems with non-UTF-8 default locales. This issue was triggered when processing firmware properties containing non-ASCII characters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant