Jump to content
krokofant

Changing encoding of autocompleted ä

Recommended Posts

I hit backspace after I wrote this post the last time and I lost all i wrote...

 

 

Test #1 (From Term​inal)

osascript -l JavaScript -e "console.log(escape('ä'))"

Notice that the ä is encoded as %E4.

 

Test #2

Create a keyword trigger with a parameter. Let's call this atest.

Create an action with osascript (JS) with the following code

console.log(escape("{query}"));

Connect the trigger and action.

Watch the debug console for output.

Notice that the ä is encoded as a%u0308.

 

 

Problem scenario

I'm using this NodeJS workflow as a base https://github.com/giangvo/alfred-workflow-nodejs/

I've created an issue about this over there too https://github.com/giangvo/alfred-workflow-nodejs/issues/6

The workflow supports autocomplete with a menusystem.

  1. I'm getting external menu entries which contains the letter ä
  2. I'm autocompleting a menu entry which places the (%E4 based ä in the search thingy)
  3. I'm sending this to an action which contains the code below
  4. function getItemData(itemTitle) {
      var wfData = Storage.get("wfData");
      return wfData ? wfData[itemTitle] : undefined;
    }
  5. This tries to access data where the menu entry title is the key. Originally the key is ä / %E4 which it is in wfData but the autocompleted title is ä / a%u0308 which makes the key not match although they at first sight look the same.

Any tip on how to go about this?

 

Latest stable update OSX El Captain

Latest Alfred v2.8.2 (432)

Share this post


Link to post
Share on other sites

Any tip on how to go about this?

 

I suspect this is the issue you are seeing:

 

http://www.alfredforum.com/topic/2015-encoding-issue/

 

You'll need to re-normalise the UTF-8, which you may be able to do in osascript / JavaScript:

 

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/normalize

 

If not, look at the 4th post down, I've shared a little shell utility which can renormalise UTF-8 on the command line after NSTask has been run.

 

Cheers,

Andrew

Share this post


Link to post
Share on other sites

I suspect this is the issue you are seeing:

 

http://www.alfredforum.com/topic/2015-encoding-issue/

 

You'll need to re-normalise the UTF-8, which you may be able to do in osascript / JavaScript:

 

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/normalize

 

If not, look at the 4th post down, I've shared a little shell utility which can renormalise UTF-8 on the command line after NSTask has been run.

 

Cheers,

Andrew

:D  :D  :D  :D 

Well this enlightened my day. Thanks for the help and for the awesome app.

 

It's alive!

Share this post


Link to post
Share on other sites

×
×
  • Create New...