Guest User

Untitled

a guest
May 31st, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. ruby incorrect method behaviour (possible depending charset)
  2. irb(main):002:0> pp "    LS 600"
  3. "302240302240302240302240LS 600"
  4.  
  5. irb(main):003:0> pp "    LS 600".strip
  6. "302240302240302240302240LS 600"
  7.  
  8. # Ruby 1.9.2 only.
  9. # Remove any whitespace-like characters from beginning/end.
  10. "302240302240LS 600".gsub(/^p{Space}+|p{Space}+$/, "")
  11.  
  12. # Ruby 1.8.7/1.9.2.
  13. $KCODE = "u"
  14. require "rubygems"
  15. require "active_support/core_ext/string/multibyte"
  16.  
  17. # Remove any whitespace-like characters from beginning/end.
  18. "302240302240LS 600".mb_chars.strip.to_s
Advertisement
Add Comment
Please, Sign In to add comment