Created
September 4, 2013 21:11
-
-
Save denisdefreyne/6442942 to your computer and use it in GitHub Desktop.
UTF-8 case that crashes in MRI and does not crash in Rubinius
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
File.write('foo.txt', 'Hëllö'.encode('ISO-8859-1')) | |
data = File.binread('foo.txt') | |
data.force_encoding('utf-8') | |
data.encode!('utf-8') | |
data.gsub!("\xEF\xBB\xBF", '') | |
# Crashes in Ruby 1.9.3p392: | |
# | |
# test.rb:8:in `gsub!': invalid byte sequence in UTF-8 (ArgumentError) | |
# from test.rb:8:in `<main>' | |
# | |
# Does not crash in Rubinius |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment