2

This question already has an answer here:

I'm trying to use enscript to print PDFs from Mutt, and hitting character encoding issues with curly quotes. So that an email with text like this:

“very dirty”    
we’re 

Comes out as:

â\200\234very dirtyâ\200\235
weâ\200\231re

My print script currently reads like this:

#!/usr/bin/env sh
INPUT="$1" PDIR="$HOME/Desktop" OPEN_PDF=evince



tmpfile="`mktemp $PDIR/mutt_XXXXXXXX.pdf`"
enscript --font=Courier8 $INPUT -2r --word-wrap --fancy-header=mutt -p - 2>/dev/null | ps2pdf - $tmpfile
$OPEN_PDF $tmpfile >/dev/null 2>&1 &
sleep 1
rm $tmpfile

Is there a way to replace the curly quotes before I send it to enscript? Or a character encoding I can use that will handle the quotes?

If there's another (better?) way to print to PDF from Mutt, I'm all ears. I just need to ensure that my quotes aren't getting fouled up.

marked as duplicate by Gilles, techraf, Anthon, HalosGhost, GAD3R Nov 20 '16 at 17:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • FWIW, the hack I settled on for this particular case (printing from Mutt, primarily concerned with curly quotes) was to create a series of sed filters I could call from .muttrc with set display_filter="sed -f /path/to/file" – Amanda Nov 20 '16 at 20:39
1

Apparently, enscript doesn't support UTF-8 files.

What you may want to do is use sed to change the quotes before they go into enscript.

This will change the fancy quotes to the standard " and '. You won't be able to get them back after they're converted. To do this, you can insert a line like the following, just above the enscript line:

sed -i "s/[”“]/\"/g; s/[‘’]/'/g" $tmpfile

You may also be able to use iconv to convert the text to some other encoding, but I don't know much about that program. May be worth looking into.

  • I wish! I tried that first and hit walls. stackoverflow.com/questions/40698444/… (And I'm fine with losing the fancy quotes for good -- that's definitely preferable to â\200\234 – Amanda Nov 20 '16 at 6:36
  • That SO exchange doesn't include trying to run sed using $tmpfile as the input but I tried that and I'm getting the same result. – Amanda Nov 20 '16 at 6:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.