tcl - How to join without losing special characters? -
i have following string:
"name\r {} {} {} {} {} other_name other_name {} {} -600.0 {} {} 860.0 {} {} -"
(i.e. string special character: \r ).
when join
line lose special charecters.
suppose:
set name "name\r {} {} {} {} {} other_name other_name {} {} -600.0 {} {} 860.0 {} {} -" set name [join $name]
now name losing special characters(at least \r
).
how resolve this?
i tried few things , came this:
set name {name\r {} {} {} {} {} other_name other_name {} {} -600.0 {} {} 860.0 {} {} -} # braces prevent substitution of \r regsub -all {\\r} $name {\\\r} name # substitution using regexp substitute \r \\r set name [join $name] # returns: "name\r other_name other_name -600.0 860.0 -"
or in case there might more characters might want escape, use more general:
regsub -all {\\} $name {\\\\} name
instead.
Comments
Post a Comment