Problem solved!
There is no issue within the code, the problem was far more subtle. For reasons unknown and a situation I’ve never seen before, the string that was being passed in (testString
), had a byte order mark at the start of it. This was never shown in any text editors, and was only realised after showing the integer value of each character of the teststring
. Copying and pasting this particular string would always copy and paste the BOM – so the error was always carried over.
Hope this helps somebody else who may have a similar issue.
solved Strange reproducible behaviour with Remove – Characters not being removed correctly