Reference my post above, I have since done much reading and muttering under my breath in an attempt to understand the difference between ³ as per a copy/paste from say windows character map and a ³ as generated from the hex notation \xB3. I am non the wiser. Even binary scanning the character shows them to have the same underlying value.
At least I am 50% happy in that I have a solution. Simply build up the regsub pattern BOTH from an explicit copy/paste of the characters themself AND from their implicit hex equivalents.
use --> [regsub -all -- {[°²³\xB0\xB2\xB3]} $varname "\\\\&"]
This is the result when I build up the variable using windows character map for the special characters :-
% set mytest "at xy³ + y² temperature is 14°"
at xy³ + y² temperature is 14°
% return [regsub -all -- {[°²³\xB0\xB2\xB3]} $mytest "\\\\&"]
at xy\³ + y\² temperature is 14\°
This is the result when I build up the variable using hex notation for the special characters :-
% set mytest "at xy\xB3 + y\xB2 temperature is 14\xB0"
at xy³ + y² temperature is 14°
% return [regsub -all -- {[°²³\xB0\xB2\xB3]} $mytest "\\\\&"]
at xy\³ + y\² temperature is 14\°
Works for both.
My guess is that this is pretty much the dirty solution the original poster found.
Please, please, somebody explain what the difference is so that I may sleep peacefully.
/me wanders off threatening a terrible revenge on all descendants of Charles Babbage.