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

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

Comments

Projects
None yet
2 participants
@YorickPeterse
Member

YorickPeterse commented Jan 28, 2014

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

This comment has been minimized.

Show comment
Hide comment
@YorickPeterse

YorickPeterse Jan 28, 2014

Member

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

Member

YorickPeterse commented Jan 28, 2014

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

@dbussink

This comment has been minimized.

Show comment
Hide comment
@dbussink

dbussink Jan 29, 2014

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.

Member

dbussink commented Jan 29, 2014

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

This comment has been minimized.

Show comment
Hide comment
@YorickPeterse

YorickPeterse Jan 29, 2014

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.

Member

YorickPeterse commented Jan 29, 2014

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