MATLAB: Searching and replacing in strings works oddly

MATLABreplacespecial charactersstring

Hi, I'm writing a GUI that should get a string, process it, and write it to a word document. I am aware that in a UiControl I cannot write any special characters, therefore I decided to write some code that would catch the "wannabe special characters" and replace them. The code is the following:
clear tbl_content1
tbl_content1 = eval(sprintf('info.data.%s.specification',structure_string))';
% We substitute the symbols with nicer ones
tbl_content1 = sprintf(tbl_content1');
tbl_content1 = regexprep(tbl_content1, '>=', '≥');
tbl_content1 = regexprep(tbl_content1, '<=', '≤');
tbl_content1 = regexprep(tbl_content1, '+/-', '±');
I take a string stored in info.data.SOMETHING.specification and try to replace >=, <= and +/-. I also tried using the function "strrep" instead of "regexprep", but the result does not change. Now, when I run the code from the GUI, the special character resulting is a "?", so I suppose something is not recognized, while if I run the code from the GUI, but stop in debug mode and go on with "F10", the executed code will show me that the character has still been changed with "?". The odd thing happens when I select the lines of code above in debug mode and press "F9", the substitution happens correctly.
Someone has any idea of why this is happening? Any suggestion would be appreciated, thank you so much.

Best Answer

Solved in the comments. Used char() to write the correct character to the source file.