You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm trying to understand what write_to_string expected to do. For example, for rosidl_runtime_c__U16String with content "Hello World", I expect that resulted std::string will also have contents "Hello World". But because write_to_string bruteforce fully copies underlay memory, I see that after every char there is a null byte (which is treated as string terminate character).
When I try to print such string I get smth like
H
e
l
l
o
W
o
r
l
d
String conversion between std::string and std::wstring is quite complex topic, coversion may not succeed (narrowing conversion from char16 to char8). I'm not generally sure that what you do here is right, because as a result you get ill-formed string.
Should instead smth like std::codecvt_utf8_utf16 be used or wstring considered unsupported by rosidl_typesupport_protobuf?
Since protobuf doesn't support wstrings so we are using bytes field to transfer wstring data, bytes field is reperesented as std::string in generated code, this function only copies wstring as is to bytes field.
Hello, I'm trying to understand what write_to_string expected to do. For example, for
rosidl_runtime_c__U16String
with content "Hello World", I expect that resultedstd::string
will also have contents "Hello World". But because write_to_string bruteforce fully copies underlay memory, I see that after every char there is a null byte (which is treated as string terminate character).When I try to print such string I get smth like
String conversion between std::string and std::wstring is quite complex topic, coversion may not succeed (narrowing conversion from char16 to char8). I'm not generally sure that what you do here is right, because as a result you get ill-formed string.
Should instead smth like std::codecvt_utf8_utf16 be used or wstring considered unsupported by rosidl_typesupport_protobuf?
More details
underlay memory
following code was used to print above
The text was updated successfully, but these errors were encountered: