Forum: Ruby on Rails single quotes become weird characters in plain-text email

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
648553f5c693d93c9ea2e042857ad22c?d=identicon&s=25 Patrick Collins (patrick99e99)
on 2007-02-09 05:44
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@budokon.com'

         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]
7aa3c32f034122ff929be64f5de237e7?d=identicon&s=25 Luciano Ramalho (Guest)
on 2007-02-09 06:15
(Received via mailing list)
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
This topic is locked and can not be replied to.