Fix missing encoding for Windows with non-utf-8 code page#45
Fix missing encoding for Windows with non-utf-8 code page#45anion0278 wants to merge 6 commits intocolcon:masterfrom
Conversation
Code page number is obtained once at ctor of the ConsoleCohesionEventHandler. The change applies only to Windows OS. For other OS the encoding remains the same "utf-8".
|
Well done! I met the same problem and solved it with this method. |
|
@Michaelmlh could you please give some examples of what results |
|
@anion0278 |
|
Maybe you should get the numeric part of the returned string, and it will avoid the first part of the string |
|
Thanks for pointing out this case! I will try to solve the issue using Regex, something like |
|
@Michaelmlh I have incorporated changes in order to make it more universal. Could you, please, test it on your machine? |
|
@anion0278 |
This change specifies the code page for string decoding in Windows. When using
decode()without theencodingparameter on Windows machine with non-utf-8 encoding ("Region - Language for non-Unicode programs" for examplecp852) the following exceptions occur:Code page number is obtained once at ctor of the
ConsoleCohesionEventHandler. The change applies only to Windows OS.For other platforms the encoding remains the same
utf-8.The reason for acquiring the codepage through the
subprocessis thatsys.stdout.encodingincorrectly returnsutf-8, while the actual encoding is different.This should represent a simple fix for the following issues:
ms-iot/ROSOnWindows#214 (comment)
ros2/ros2_documentation#654
https://answers.ros.org/question/351567/ros2-colon-building-turtlesim-package-failed/