Ruby 2.0.0 String#Match ArgumentError: invalid byte sequence in UTF-8

前端 未结 2 1492
挽巷
挽巷 2021-02-05 03:15

I see this a lot and haven\'t figured out a graceful solution. If user input contains invalid byte sequences, I need to be able to have it not raise an exception. For example:<

2条回答
  •  一生所求
    2021-02-05 04:00

    Since you're using Rails and not just Ruby you can also use tidy_bytes. This works with Ruby 2.0 and also will probably give you back sensible data instead of just replacement characters.

提交回复
热议问题