Even the code is there for doing the translation, it does not work because you remove spaces "~" before reaching the conversion.
I propose you a work-around that is making the space removal at the end of the function after have checking for conversions that use "~"