Created
October 10, 2015 04:13
-
-
Save ptagell/78929397ebdb6a079660 to your computer and use it in GitHub Desktop.
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
irb(main):129:0> value_to_evaluate | |
=> "\u00001\u00004\u00009\u00003\u0000" | |
irb(main):130:0> puts value_to_evaluate | |
1493 | |
=> nil | |
irb(main):131:0> value_to_evaluate == 1493 | |
=> false | |
irb(main):132:0> |
Where is the data in value_to_evaluate
coming from? It looks like it might be utf16, which isn't a very common encoding in ruby-land.
You could try this to mark it as UTF-16, then convert it to UTF-8 (which is more common and usable in ruby)
value_to_evaluate_utf8 = value_to_evaluate.force_encoding("UTF-16BE").encode("UTF-8")
value_to_evaluate_utf8.to_i == 1493
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have no idea why but this works