Implement a UTF-16 correction function which replaces bad surrogate pairs with the replacement character.