From: "Erik E." Date: 2011-01-13T08:06:15+09:00 Subject: Re: String.strip with UTF-8 Thank you for quick reply David & Peter, I was upgrading Ruby to see if it made a difference, but I can see it's not a space now which explains why it didn't strip Loading development environment (Rails 3.0.3) ruby-1.9.2-p136 :001 > d = Domain.last => # ruby-1.9.2-p136 :002 > d.entity => " United Arab Emirates" ruby-1.9.2-p136 :003 > d.entity.class => String ruby-1.9.2-p136 :004 > d.entity.encoding => # ruby-1.9.2-p136 :005 > d.entity[0].ord => 160 ruby-1.9.2-p136 :006 > d.entity.bytes.to_a => [194, 160, 85, 110, 105, 116, 101, 100, 32, 65, 114, 97, 98, 32, 69, 109, 105, 114, 97, 116, 101, 115] Peter Vandenabeele wrote in post #974440: > > Hi, I made a fresh install with rvm 1.9.2-p0 and rails 3.0.3 > and I cannot reproduce your problem. Maybe you could try to > replay what I did and see if you can still reproduce it ? > > Also, to examine that first character in detail, what is the > result when you try this: > > 009:0> d.entity.bytes.to_a[0..5] > => [32, 85, 110, 105, 116, 101] > > I see a "regular" space (character 32 in decimal notation) > as first character. > > HTH, > > Peter > > Loading development environment (Rails 3.0.3) > 001:0> IRB.prompt_mode=:RVM # this is a local patch > => :RVM > ruby-1.9.2-p0 :002 > d = D.create :entity => " United Arab Emirates" > => # 22:31:21", updated_at: "2011-01-12 22:31:21"> > ruby-1.9.2-p0 :003 > d.entity > => " United Arab Emirates" > ruby-1.9.2-p0 :004 > d.entity.strip > => "United Arab Emirates" > ruby-1.9.2-p0 :005 > d.entity.class > => String > ruby-1.9.2-p0 :006 > d.entity.encoding > => # > ruby-1.9.2-p0 :007 > exit > > peterv@ASUS:~/ra/apps/trials/issue_with_strip$ rails c > Loading development environment (Rails 3.0.3) > 001:0> d = D.find :last > => # 22:31:21", updated_at: "2011-01-12 22:31:21"> > 002:0> d.entity > => " United Arab Emirates" > 003:0> d.entity.strip > => "United Arab Emirates" -- Posted via http://www.ruby-forum.com/.