Reputation: 16779
Check out the weird behavior I'm getting with two strings. I suspect of course, that the space isn't really a space. How do I investigate this?
Upvotes: 2
Views: 95
Reputation: 138032
Try something like:
1.9.2p290> "foo bar".bytes.to_a # the space is a nonbreaking-space
=> [102, 111, 111, 194, 160, 98, 97, 114]
or if hex codes for characters are your thing:
1.9.2p290> "foo bar".chars.map { |c| c.unpack "H*" } # same nonbreaking-space
=> [["66"], ["6f"], ["6f"], ["c2a0"], ["62"], ["61"], ["72"]]
Upvotes: 5