Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspect binary data bug #2159

Closed
kostya opened this issue Feb 15, 2016 · 2 comments
Closed

Inspect binary data bug #2159

kostya opened this issue Feb 15, 2016 · 2 comments

Comments

@kostya
Copy link
Contributor

kostya commented Feb 15, 2016

crystal eval 'p File.read("/home/kostya/1.png")'
Invalid byte sequence in UTF-8 string (InvalidByteSequenceError)
ruby -e 'p File.read("/home/kostya/1.png")'
"\x89PNG\r\n\u001A\n\u0000\u0000\u0000\rIHDR\u0000\u0000\u0000A\u0000\u0000\u0000A\b\u0002\u0000\u0000\u0000\u0001\x95^\u0012\u0000\u0000\a\x89IDATh\x81\xEDZOL\u0014W\u0018\x9F\u001D\u0016\xD9MwH\xC7.Ig\x96=\xB8\av:\xDBJʺ\x86F\xD2\u0003\u0010\x9B\xAA\u000

in some places i just want to inspect data to debug it, but get this exception

@asterite
Copy link
Member

Yes, I agree this is annoying. inspect should be resilient here. Or maybe String.new(...) should raise if it's not properly encoded in UTF-8. Related to #2130

@miketheman
Copy link
Contributor

#triage
Still an issue, the only part that has changed is a more informative error message:

Unexpected byte 0x89 at position 0, malformed UTF-8 (InvalidByteSequenceError)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants