My Kind of Stupid

Web development, user interfaces, and other development topics.

Quoted-printable in Ruby

I'm working on reading emails sent from ActionMailer, and was noticing the weird form of what I thought was URL-encoding in an HTML section of a multipart email, e.g.

<html lang=3D"en">

I also noticed the line length and endings:

blah blah … blah bl=
ah blah blah

I shrugged these off as quirks of ActionMailer or SMTP and moved on to removing/decoding them.

Two hours later, when googling for info about them because they didn't seem consistent, I stumbled across Quoted-printable encoding. I recognized it from the headers in the email, and wondered if someone had written a gem or something to decode it. Then I find this - String#unpack was able to do it for me all along.

It's great that Ruby (and sometimes Rails) can do things like this out of the box. I just wish I was smart enough to look.

Published at