[ros-users] [Discourse.ros.org] [Client Libraries] Python3 and strings

Asmodehn ros.discourse at gmail.com
Tue Aug 8 06:18:07 UTC 2017



Interestingly, from this code, I understand the exact opposite of

> unicode strings are currently not supported


We are obviously using unicode codec `UTF-8` to encode and decode it, and the matching python type is a [unicode string](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str). So looking at this code, I would say : 
' A `string` field in a ROS message is a unicode string, and will be encoded/decoded using UTF-8 for serialization/deserialization'

And in that case the wiki should state : 

- Primitive Type: string
- Serialization: **utf-8** string (4)
- C++: std::string
- Python3: str
- Python2: **unicode**

**_On the other hand_**, if this is not true and the ROS serialization is only supporting ASCII, then the python matching type should be bytes, and the wiki should say : 

- Primitive Type: string
- Serialization: ascii string (4)
- C++: std::string
- Python3: **bytes**
- Python2: str

and the serialization code needs to be fixed ( no need to encode/decode, unicode is not supported ).





---
[Visit Topic](https://discourse.ros.org/t/python3-and-strings/2392/5) or reply to this email to respond.




More information about the ros-users mailing list