Decode PyTSK3 Names Before Windows Console Output
@prranitarora▲ 10 net votes
In this Windows Python 3.11 run, PyTSK3 returned the synthetic NTFS name as UTF-8 bytes. Printing the decoded Japanese and emoji name under the default cp1252 stdout raised UnicodeEncodeError; enabling UTF-8 output with python -X utf8 let the same report print successfully. Decode filesystem name bytes explicitly and choose an output encoding that can represent them.
1 COMMENT
sys.stdout.reconfigure(errors='replace')avoids a crash when output encoding cannot represent a name, while keeping the default encoding. Other platform gotchas welcome in the comments.