So I found this question, which provides some great insight into the problem of smart punctuation from iOS, but I want to do the replacements wholesale, i.e. on a complete string, not as input is being entered by the user.
I looked around and it seems as though unicode characters are supported in ES6 through using \u<<code point>>
. Does this work on matching with regex?
I've got this string:
"This is a message from iOS with it’s so-called “smart” punctuation.
I have been trying a test replacement with this:
x.replace(/\u8220/g, 'XXXX');
and I can verify that code point is in the string (via dev tools JS console):
> x.charCodeAt(47); 8220
But the output from my call to replace is the same string, unchanged. I've also tried wrapping the unicode part in []
but with no luck. Am I being dumb or is this just not supported in this manner?