-
Notifications
You must be signed in to change notification settings - Fork 142
Fix default wstring length #862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rolling
Are you sure you want to change the base?
Conversation
2360fe6 to
6eba9f8
Compare
6eba9f8 to
8c50d41
Compare
Signed-off-by: Anthony Welte <[email protected]>
fujitatomoya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks good to me, just a minor nitpick.
i would like to have an another review for this PR before merge.
|
Pulls: #862 |
8c50d41 to
0c29c98
Compare
|
Pulls: #862 |
Signed-off-by: Anthony Welte <[email protected]>
0c29c98 to
52876f4
Compare
|
Looks like the RHEL build uses an older Python version (before 3.12) which doesn't like strings within fstrings. I've pushed the following modification: """Statically define a runtime Sequence or String type."""
if values:
if isinstance(values, str):
- return f'{{{varname}, {len(values.encode('utf-8'))}, {len(values.encode('utf-8'))}}}'
+ utf8_values = values.encode('utf-8')
+ return f'{{{varname}, {len(utf8_values)}, {len(utf8_values)}}}'
else:
return f'{{{varname}, {len(values)}, {len(values)}}}'
return '{NULL, 0, 0}' |
|
Pulls: #862 |
|
After using this fix with our interfaces we noticed another bug that could cause issues once this is merged. If a Unicode character is directly followed by 0-9 or a-f, we get a warning The solution would be to split the string after a Unicode sequence by adding char test[] = "Temperature \xc2\xb0C";into char test[] = "Temperature \xc2\xb0""C";see https://godbolt.org/z/5rPKh4qa9 I can attempt a fix in this MR or make a new one. What do you think @fujitatomoya ? |
|
@TonyWelte to be honest, i am not sure about that. |
This PR fixes strings containing unicode characters not being escaped properly and their size being inaccurate. For instance on WString it results in the following change
It also fixes
"and'being over escaped (and some other escaped characters). For instance on https://github.com/Tonywelte/test_interface_files/blob/rolling/msg/Strings.msg (see ros2/test_interface_files#25)Additional notes
+1instatic_seqbut fortoplevel_type_raw_sourceit should be-1. I'm not sure what's the difference.\'and\"are mentioned in https://design.ros2.org/articles/legacy_interface_definition.html but other (\\and\t) worked in rosidl_generator_cpp but rosidl_generator_c didn't escape them properly.\ndoesn't work at all.Fixes #855