From 825377083862dea1bba3dba083b5dec98fa92712 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Thu, 14 Oct 2021 13:00:31 -0700 Subject: [PATCH] Escape default arrays and sequences the same other default values Fix #610 Apply the same encode/decode pattern and escaping as for other default values. Signed-off-by: Jacob Perron --- rosidl_adapter/rosidl_adapter/msg/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rosidl_adapter/rosidl_adapter/msg/__init__.py b/rosidl_adapter/rosidl_adapter/msg/__init__.py index b02b7b5bd..cff0b3306 100644 --- a/rosidl_adapter/rosidl_adapter/msg/__init__.py +++ b/rosidl_adapter/rosidl_adapter/msg/__init__.py @@ -61,7 +61,9 @@ def convert_msg_to_idl(package_dir, package_name, input_file, output_dir): def to_idl_literal(idl_type, value): if idl_type[-1] == ']' or idl_type.startswith('sequence<'): - content = repr(tuple(value)).replace('\\', r'\\').replace('"', r'\"') + content = repr(tuple(value)).replace('\\', r'\\') + content = content.encode().decode('unicode_escape') + content = content.replace('"', r'\"').replace("'", r"\'") return f'"{content}"' if 'boolean' == idl_type: