JSON encoding Windows-1252 Unicode chars

While trying to use the json_encode function a Windows-1252 left and right quote character was breaking the encoding and I was ending up with no JSON. The string being encoded was from html within a PHP file. I’m guessing it was copy pasted from a Word doc.

To fix this the mb_convert_encoding function, not the utf8_encode function, was needed. From the utf8_encode docs:  “This function will not convert such Windows-1252 characters correctly. Use a different function if Windows-1252 conversion is required”. mb_convert_encoding turned out to be the “different function”.

The function call ended up looking like this:
mb_convert_encoding($new_selection['new_string'], 'UTF8', array('Windows-1252'))