Patrick Collins
2007-Feb-09 04:44 UTC
single quotes become weird characters in plain-text email
When sending plain-text via a rails app, I am finding that single quotes cause a very strange character code to appear... I am wondering what the cause of this is, and how to fix it. This is how the email appears.. notice the problem with "MEN''S" and "WOMEN''S": http://www.collinatorstudios.com/www/budokonmail1.png -patrick this is the code I have currently for mailing email: [code] class Mailer < ActionMailer::Base def send_newsletter(newsletter, contact) return false unless contact.primary_email && contact.primary_email =~ /\w+@\w+\.[\w.]+/ begin recipients contact.primary_email subject newsletter.subject from ''newsletter-lNJsxkhOqSFBDgjK7y7TUQ@public.gmane.org'' part "text/plain" do |p| if newsletter.newsletter.length == 0 p.body = "" else greeting = contact.first_name || ''Hello'' p.body = "#{greeting},\n\n" + newsletter.newsletter end end newsletter.attachments.each do |attachment| part attachment.content_type do |p| p.body = attachment.contents p.filename = attachment.filename p.transfer_encoding = ''base64'' end end rescue return false end return true end end [/code] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Luciano Ramalho
2007-Feb-09 05:14 UTC
Re: single quotes become weird characters in plain-text email
You are not using ASCII single quotes. If you were, that would not happen. The program you are using to write the e-mail body is using "smart quotes". Use a plain text editor to compose the message, or include a mail header identifying the encoding of the body as UTF-8. Cheers, Luciano On 2/9/07, Patrick Collins <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > When sending plain-text via a rails app, I am finding that single quotes > cause a very strange character code to appear... I am wondering what > the cause of this is, and how to fix it. This is how the email > appears.. notice the problem with "MEN''S" and "WOMEN''S": > > http://www.collinatorstudios.com/www/budokonmail1.png > > -patrick > > this is the code I have currently for mailing email: > > [code] > class Mailer < ActionMailer::Base > def send_newsletter(newsletter, contact) > return false unless contact.primary_email && contact.primary_email > =~ /\w+@\w+\.[\w.]+/ > > begin > recipients contact.primary_email > subject newsletter.subject > from ''newsletter-lNJsxkhOqSFBDgjK7y7TUQ@public.gmane.org'' > > part "text/plain" do |p| > if newsletter.newsletter.length == 0 > p.body = "" > else > greeting = contact.first_name || ''Hello'' > p.body = "#{greeting},\n\n" + newsletter.newsletter > end > end > > newsletter.attachments.each do |attachment| > part attachment.content_type do |p| > p.body = attachment.contents > p.filename = attachment.filename > p.transfer_encoding = ''base64'' > end > end > rescue > return false > end > > return true > end > end > > > [/code] > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---