So I've been struggling with a problem.
If I just output it, things such as "tm" (utf-8 encoded) comes out as 3-4 random characters.
I tried various functions I've found on the internet
but have had no luck. The most promising was the second, which was the use of the function decodeURIComponents. This worked in Safari.
But in Firefox and IE it caused an error "malformed URI sequence" which was presumably from some characters in the text.