@@ -106,14 +106,17 @@ symbol_exprt get_or_create_string_literal_symbol(
106106 // contents as well:
107107 if (string_refinement_enabled)
108108 {
109+ const array_exprt data =
110+ utf16_to_array (utf8_to_utf16_little_endian (id2string (value)));
111+
109112 struct_exprt literal_init (new_symbol.type );
110113 literal_init.operands ().resize (jls_struct.components ().size ());
111114 const std::size_t jlo_nb = jls_struct.component_number (" @java.lang.Object" );
112115 literal_init.operands ()[jlo_nb] = jlo_init;
113116
114117 const std::size_t length_nb = jls_struct.component_number (" length" );
115118 const typet &length_type = jls_struct.components ()[length_nb].type ();
116- const exprt length = from_integer (id2string (value ).size (), length_type);
119+ const exprt length = from_integer (data. operands ( ).size (), length_type);
117120 literal_init.operands ()[length_nb] = length;
118121
119122 // Initialize the string with a constant utf-16 array:
@@ -127,8 +130,7 @@ symbol_exprt get_or_create_string_literal_symbol(
127130 // These are basically const global data:
128131 array_symbol.is_static_lifetime = true ;
129132 array_symbol.is_state_var = true ;
130- array_symbol.value =
131- utf16_to_array (utf8_to_utf16_little_endian (id2string (value)));
133+ array_symbol.value = data;
132134 array_symbol.type = array_symbol.value .type ();
133135
134136 if (symbol_table.add (array_symbol))
0 commit comments