Skip to content

Instantly share code, notes, and snippets.

@mchataigner
Created July 3, 2013 08:54
Show Gist options
  • Save mchataigner/5916460 to your computer and use it in GitHub Desktop.
Save mchataigner/5916460 to your computer and use it in GitHub Desktop.
sublime text 3 plugin to encode and decode quoted printable texts
[
{
"caption": "QuoPriEncDec: quotedprintable encode",
"command": "quo_pri_enc"
},
{
"caption": "QuoPriEncDec: quotedprintable decode",
"command": "quo_pri_dec"
}
]
import sublime, sublime_plugin, os, email.quoprimime
class QuoPriEnc(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
for region in view.sel():
if not region.empty():
s = view.substr(region)
s = email.quoprimime.body_encode(s.encode("utf-8").decode("latin-1"))
view.replace(edit, region, s)
class QuoPriDec(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
for region in view.sel():
if not region.empty():
s = view.substr(region)
s = email.quoprimime.body_decode(s).encode("latin-1").decode("utf-8")
view.replace(edit, region, s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment