Hello NXP Support Team,
While building the NXP Matter light-switch-combo-app in the MCUXpresso VS Code environment on Windows, the build fails during the code generation step (scripts/codegen.py) with a UnicodeDecodeError ('cp932'). ZAP generation succeeds; only the codegen step fails. Could you advise on the root cause and the recommended fix?
OS: Windows 11 (Japanese locale, default code page cp932)
Tooling: MCUXpresso VS Code (standard Matter setup)
Python: 3.10 (C:\nxp_matter_v1_4_0_2_1\venv\Scripts\python.exe)
Example: examples/light-switch-combo-app (Wi-Fi/Combo)
Matter repository (NXP fork): https://github.com/NXP/matter
Release in use: v1.4.0_2_1 (local path name: nxp_matter_v1_4_0_2_1)
Inputs:
IDL: light-switch-combo-matter-wifi.matter
ZAP: light-switch-combo-matter-wifi.zap
ZAP CLI: log shows zap version: 2024.10.24 (generation succeeds)
Set up NXP Matter v1.4.0_2_1 on Windows 11.
Build examples/light-switch-combo-app from MCUXpresso VS Code.
During ninja, the following codegen step fails.
C:\nxp_matter_v1_4_0_2_1\venv\Scripts\python.exe C:/nxp_matter_v1_4_0_2_1/scripts/codegen.py \
--generator cpp-app \
--output-dir C:/nxp_matter_v1_4_0_2_1/examples/light-switch-combo-app/nxp/debug/gen/app-codegen/cpp-app \
--expected-outputs C:/nxp_matter_v1_4_0_2_1/examples/light-switch-combo-app/nxp/debug/gen/app-codegen/cpp-app/expected.outputs \
C:/nxp_matter_v1_4_0_2_1/examples/light-switch-combo-app/light-switch-combo-common/light-switch-combo-matter-wifi.matter
INFO Parsing idl from .../light-switch-combo-matter-wifi.matter
...
UnicodeDecodeError: 'cp932' codec can't decode byte 0x99 in position 11484: illegal multibyte sequence
(ZAP generation completes and produces zap-generated/*.h, *.cpp.)
codegen.py seems to read the .matter file via open(..., "rt") using the default locale encoding (cp932 on Japanese Windows). If the file is UTF-8, certain bytes (e.g., 0x99) cannot be decoded under cp932, causing the exception.
Only the .matter → C++ path fails; ZAP generation is unaffected.
Is UTF-8 the expected encoding for .matter files on Windows (non-UTF-8 locales)?
Will scripts/codegen.py be updated to explicitly specify encoding="utf-8" when reading the IDL?
Is there an officially recommended workaround (e.g., PYTHONUTF8=1, chcp 65001 before build, converting .matter to UTF-8 w/o BOM) until a fix lands?
Is this specific to v1.4.0_2_1? If a fix is planned for a future release, could you share the timeline?
chcp 65001: no change (Python’s default file encoding may still follow locale/implementation)
PYTHONUTF8=1: not yet confirmed (would like official guidance)
Re-saving the .matter file as UTF-8 (no BOM): likely to help, but we prefer an official, maintainable approach.
Best regards,
Naoki Hayashi