ros / console_bridge

A ROS-independent package for logging that seamlessly pipes into rosconsole/rosout for ROS-dependent packages.
BSD 3-Clause "New" or "Revised" License
22 stars 62 forks source link

cannot print chinese by roslog #49

Closed DinnerHowe closed 5 years ago

DinnerHowe commented 6 years ago

hi, there: We found ROS cannot print Chinese by c++, like" 我是新手 ". For instance, ROS_INFO(" 我是新手 "), the result is [ INFO] [1512552131.271037807]: ???????????? However, in python ROS could print Chinese well. Is this issue caused by pointer? like: const char m in void console_bridge::log(const char file, int line, LogLevel level, const char* m, ...) @wjwwood

scpeters commented 6 years ago

maybe we need to use std::wstring in the API?

DinnerHowe commented 6 years ago

yes, i think so. also, i tried input a wstring to ROS_INFO, it cannot pass catkin make yet:

    std::wstring aa;
    aa = "我是新手";
    ROS_INFO(aa);

the error is error: invalid conversion from ‘const char*’ to ‘wchar_t’ [-fpermissive]

ghost commented 5 years ago

Anyone knows solution ?

scpeters commented 5 years ago

I just added a small test case in console_bridge to print Chinese characters, and it appears to work for me: https://github.com/scpeters/console_bridge/commit/2c95bdd6f335178d960603fdd0116ecf685978d8

Perhaps the problem is farther downstream in ROS?

scpeters commented 5 years ago

https://travis-ci.org/scpeters/console_bridge/jobs/452058400#L526

wjwwood commented 5 years ago

rosout sends the logs as an ascii string in the topics, see:

https://github.com/ros/ros_comm_msgs/blob/bfb8533fd6c6e959c71f0d2a9669baeff2dac1ad/rosgraph_msgs/msg/Log.msg#L15

I do not believe this can be fixed because ROS 1's type system doesn't support wide strings.

Will support them in ROS 2 though, so maybe we should put that (should support unicode messages) as input to the ongoing work for the logging subsystem in ROS 2:

https://discourse.ros.org/t/ros2-logging/6469

scpeters commented 5 years ago

thanks @wjwwood

I added a comment that we should support this in ros2

I will close this issue since it is not a problem with console_bridge