Skip to content

Rbx marks strings as having a valid encoding when MRI does not #2910

Closed
YorickPeterse opened this Issue Jan 28, 2014 · 3 comments

2 participants

@YorickPeterse
Rubinius member

Take the following basic code for example:

"foo".force_encoding(Encoding::UTF_32).valid_encoding?

On MRI this would return false whereas on Rubinius it returns true. My encoding-fu is not big enough to figure out which one is correct. The mere difference however could potentially introduce weird bugs.

@YorickPeterse
Rubinius member

Simple way to run the above: ruby -e 'p "foo".force_encoding(Encoding::UTF_32).valid_encoding?'

@dbussink
Rubinius member

Looks like this behaves the same as MRI. That also returns true. Note that Encoding::UTF_32 is not a real encoding, but a dummy one. If you use Encoding::UTF_32BE you see it will return false on both MRI and Rubinius.

@dbussink dbussink closed this Jan 29, 2014
@YorickPeterse
Rubinius member

Ah, seems that indeed on MRI 2.1 this would return false. On MRI 1.9.3 it returns true so I guess that was a bug at the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.