You didn’t try the whole thing as I sent it to you. Use the curl braces where I have used them and then use the subst command.
What my code does is replace each instance of a non-ascii code with the string: x0[format %02x [scan %c]]
Where above is the character found.
You then run the subst command to cause the commands to execute
regsub -all — {[^x00-x7F]} $name {\x0[format %02x [scan & %c]]} tmp
set result [subst $tmp]
I would put the regsub in an if statement and only execute the subst if a change was made.