Skip to content

Instantly share code, notes, and snippets.

@henix
Last active December 17, 2015 04:48
Show Gist options
  • Save henix/5552766 to your computer and use it in GitHub Desktop.
Save henix/5552766 to your computer and use it in GitHub Desktop.
quoted-printable decode scala script # for manually decode an email
#!/bin/sh
REPO=~/.m2/repository
exec scala -classpath $REPO/commons-io/commons-io/2.4/commons-io-2.4.jar:$REPO/javax/mail/mail/1.4.6/mail-1.4.6.jar:$REPO/javax/activation/activation/1.1.1/activation-1.1.1.jar "$0" "$@"
!#
import java.io.InputStreamReader
import java.nio.charset.Charset
import javax.mail.internet.MimeUtility
import org.apache.commons.io.IOUtils
if (args.length != 1) {
println("Usage: ./qpdecode.scala charsetName < file")
System.exit(1)
}
val charset = Charset.forName(args(0))
IOUtils.copy(new InputStreamReader(MimeUtility.decode(System.in, "quoted-printable"), charset), System.out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment