I have a JavaScript string that I'm writing to a file. I need to replace any unmatched surrogate pairs with the replacement character. Is there some regex character class that only matches unpaired surrogates or do I have to do some additional processing?
String.prototype.toWellFormed()
replaces any lone surrogates with the Unicode replacement character U+FFFD �
.