Mysql - Mysql2::Error: Incorrect string value:

后端 未结 3 1224
说谎
说谎 2021-02-03 12:12

So I built a scraper and am pulling in some objects. The issue is some are foreign languages and it is tripping the mysql db up a bit. This is the error I got. Any idea what I c

3条回答
  •  萌比男神i
    2021-02-03 13:09

    This can also be triggered if the string you're trying to insert has invalid UTF-8 byte sequences. For example, in ruby you can remove any invalid characters using

    string_with_invalid_sequences.encode('utf-8', 'binary', invalid: :replace, undef: :replace, replace: '')
    

    String#scrub can be used in ruby 2.1 onwards

    string_with_invalid_sequences.scrub
    

提交回复
热议问题