I have a string coming from an email body : (rdb:1) body "\r\nLe 3 sept. 2010 \340 19:06, Event Seve Test a \351crit :\r\n\r\n> Please answer the question by writing an X at the chosen places :\r\n> \r\n> are you coming : \r\n> \r\n> YES: X\r\n> \r\n> NO:_\r\n> \r \n> thanks for you answer\r\n> \r\n> the Seve Ballesteros" when I want to resent this boy in another email, I get an error , stating invalid byte sequence .. sure the \r\n are causing the error (rdb:1) sending_confirmation_email(@origin, @destination, @subject, @message) ArgumentError Exception: invalid byte sequence in UTF-8 should I strip them ? or is there any way to re-encode the string in UTF-8 ??? ( Ruby 1.8.3 and Ruby 1.9.2 ) thanks for your help erwin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeffrey L. Taylor
2010-Sep-07 00:45 UTC
Re: invalid byte sequence in UTF-8 , need to re-encode ?
Quoting Erwin <yves_dufour-ee4meeAH724@public.gmane.org>:> > > I have a string coming from an email body : > (rdb:1) body > "\r\nLe 3 sept. 2010 \340 19:06, Event Seve Test a \351crit :\r\n\r\n> > Please answer the question by writing an X at the chosen places :\r\n> > \r\n> are you coming : \r\n> \r\n> YES: X\r\n> \r\n> NO:_\r\n> \r > \n> thanks for you answer\r\n> \r\n> the Seve Ballesteros" > > when I want to resent this boy in another email, I get an error , > stating invalid byte sequence .. sure the \r\n are causing the error > > (rdb:1) sending_confirmation_email(@origin, @destination, @subject, > @message) > ArgumentError Exception: invalid byte sequence in UTF-8 > > should I strip them ? or is there any way to re-encode the string in > UTF-8 ??? ( Ruby 1.8.3 and Ruby 1.9.2 ) >What is the original encoding? It doesn''t look like UTF-8. \r and \n are ASCII and so okay in UTF-8. It is the \340 and \351 that look suspicious. Jeffrey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.