在進行 regular expression 或其他字串處理時, 出現以下錯誤訊息
1
| Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8
|
來源
https://rails.lighthouseapp.com/projects/8994/tickets/4336-ruby19-submitted-string-form-parameters-with-non-ascii-characters-cause-encoding-errors
解決
1
| mystring.force_encoding("UTF-8")
|
總之就是把所有的字串都 force_encoding :p