Created
July 3, 2013 08:54
-
-
Save mchataigner/5916460 to your computer and use it in GitHub Desktop.
sublime text 3 plugin to encode and decode quoted printable texts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
[ | |
{ | |
"caption": "QuoPriEncDec: quotedprintable encode", | |
"command": "quo_pri_enc" | |
}, | |
{ | |
"caption": "QuoPriEncDec: quotedprintable decode", | |
"command": "quo_pri_dec" | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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