Sublime Forum

Encoding issues in plugin

#1

Hi!

I’ve made a plugin that takes a search query in a input panel, does a google search for that and returns a quick panel with the 10 first results. It then runs a snippet, on your selected text, with the result you picked, in markdown.

It works wonderfully, except I need to encode the google-result as pure ASCII for the quick panel to accept the input. Which is non-optimal for me, as I am swedish, and really like to have my å, ä and ö:s to stay in their respective places in the link title.

Is there something I’ve missed or is it possible that ST2 will have support for utf-8 in the quick panel in the future?

Anyhow, I really really love ST2, it’s a wonderful editor! :smiley:

0 Likes

#2

ST2 API use unicode string.
It’s your job to convert your string to unicode otherwise Python try to decode it as ASCII, it’s probably your problem here.

myunistr = myutf8str.decode('utf8') myunistr = "Planète".decode('utf8')
Replace myutf8str with your string and ‘utf8’ with the encoding of your string.

0 Likes

#3

Thank you bizoo!

You were totally right, just removing the encode-methods made it work, it was already unicode strings :smiley:

Anyone know if there is interest in including this plugin in the Package Control-repository?

0 Likes