Use Ruby native encoding functionality under Ruby 1.9+ to silence Iconv deprecation warnings.