Handling 'incorrect string values'

Problem

I'm scraping the text from websites and putting it in a database, but one website's text keeps giving me this error when I try to do the database insertion:

Error: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect string value: '\xC2\x80\xC2\x99 s...' for column 'text' at row 1

I think this has something to do with character encoding. Is there a function in javascript I can use to simply ignore these incorrect values? It's not critically important that the saved text matches the original perfectly. Alternatively, is there some mysql configuration I can do to support these characters?

Problem courtesy of: John

Solution

I fixed this by adding 'charset : utf-8' to the mysql connection parameters.

Solution courtesy of: John

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.