I was trying to use/adapt this code (http://mcgivrer.fr/sublime-text-2-the-killer-source-editor) in order to looking up on several websites such WordReference and others. If the selected text doesn’t have accents the code runs out of the box, but if selected text comes with accents or so (characters like ç, ã, ñ, ê…) it simply doesn’t work for me
import sublime, sublime_plugin, webbrowser
class OpenBrowserCommand(sublime_plugin.TextCommand):
def run(self, edit, url):
selection = ""
for region in self.view.sel():
selection += self.view.substr(region)
webbrowser.open_new_tab(url.format(search=selection))
I’m not a programmer (I’m just a common copywriter ) but I tried to encode the string with several alternatives such as: u"", encode(string), string.encode(“utf-8”)… declaring encoding at the beginning of the script… without success.
Could you help with some tip I can use? I just want to create some text-filter (snippets for ReST and other text hijack: replacements, translations) and some web-lookup plugin like this. Maybe you can recommend me some page or example.
Thanks a lot!