enable `detect_encoding!` for ruby 2

`detect_encoding!` only works with 1.9, this pull enables it for ruby 2 as well