How can I globally ignore invalid byte sequences in UTF-8 strings?

后端 未结 5 831
傲寒
傲寒 2021-02-05 08:14

I have an Rails application surviving from migrations since Rails version 1 and I would like to ignore all invalid byte sequences on it, to keep the backwards c

5条回答
  •  广开言路
    2021-02-05 08:58

    In ruby 2.0 you could use the String#b method, that is a short alias to String#force_encoding("BINARY")

提交回复
热议问题