On Windows, if you redirect console output to a file or pipe, and if there are non-ascii unicode characters in your output, you may get failure with an error message about the wrong code page. The reason is obscure, and discussed here with solutions:
tl;dr - When you redirect the output, Windows uses the system locale encoding instead of the console encoding. Even if the console encoding is 65001 (quasi-utf-8), the local encoding is probably using still using cp1252 (ascii) or similar. Windows 11 may have a different behavior.