Skip to content

Commit

Permalink
Merge pull request #1 from titoBouzout/master
Browse files Browse the repository at this point in the history
Unicode Fix for URI encode/decode.
Renamed "URL Encode/Decode" to "URI Component Encode/Decode"
  • Loading branch information
dangelov committed Feb 18, 2012
2 parents 6919613 + 42a4e0b commit ac80fa9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
package-metadata.json
*.pyc
8 changes: 4 additions & 4 deletions Main.sublime-commands
Expand Up @@ -20,13 +20,13 @@
"args": {}
},
{
"caption": "Hasher: URL Encode",
"command": "url_encode",
"caption": "Hasher: URI Component Encode",
"command": "uri_component_encode",
"args": {}
},
{
"caption": "Hasher: URL Decode",
"command": "url_decode",
"caption": "Hasher: URI Component Decode",
"command": "uri_component_decode",
"args": {}
},
{
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -6,7 +6,7 @@ Hasher is a small Sublime Text 2 Plugin that generates hashes from the selected
* SHA1
* Base64 Encode
* Base64 Decode
* URL Encode
* URL Decode
* URI Component Encode
* URI Component Decode

More to come.
13 changes: 6 additions & 7 deletions hasher.py
@@ -1,5 +1,3 @@
import string
import sublime
import sublime_plugin
import hashlib
import urllib
Expand Down Expand Up @@ -52,25 +50,26 @@ def run(self, edit):
txt = base64.b64decode(selected)
self.view.replace(edit, s, txt)

class UrlEncodeCommand(sublime_plugin.TextCommand):
class UriComponentEncodeCommand(sublime_plugin.TextCommand):
def run(self, edit):
for s in self.view.sel():
if s.empty():
s = self.view.word(s)

selected = self.view.substr(s)
txt = urllib.quote(selected)
txt = urllib.quote(selected.encode('utf8'), '')
self.view.replace(edit, s, txt)

class UrlDecodeCommand(sublime_plugin.TextCommand):
class UriComponentDecodeCommand(sublime_plugin.TextCommand):
def run(self, edit):
for s in self.view.sel():
if s.empty():
s = self.view.word(s)

selected = self.view.substr(s)
txt = urllib.unquote(selected)
self.view.replace(edit, s, txt)
txt = urllib.unquote(selected.encode('utf8'))
txt = unicode(txt.decode('utf8'));
self.view.replace(edit, s, txt);

class CurrentUnixTimestamp(sublime_plugin.TextCommand):
def run(self, edit):
Expand Down
Binary file removed hasher.pyc
Binary file not shown.

0 comments on commit ac80fa9

Please sign in to comment.