Jump to content

Encoding and Decoding Workflow


Recommended Posts

  • 1 month later...

The decode portion of this workflow fails for me. It drops through to the default "Search Google for '....'". For example:

encode 1,2

 correctly yields 1%2C2 with preview and copy-to-clipboard.

decode 1%2C2

results in the google search option coming up. The same thing happens if I wrap 1%2C2 in quotes.

 

Any ideas?

Link to comment
  • 4 weeks later...
  • 2 months later...
  • 4 weeks later...

I looked into it.
Using the alfred debugger `alfred -f encode.php -q "ü ö ä"`

 

```

<?xml version="1.0"?>

<items><item uid="URL Encoded" arg="%C3%BC+%C3%B6+%C3%A4" valid="yes" autocomplete=""><title>%C3%BC+%C3%B6+%C3%A4</title><subtitle>URL Encoded</subtitle><icon>icon.png</icon></item><item uid="UTF8 Encoded" arg="ü ö ä" valid="yes" autocomplete=""><title>ü ö ä</title><subtitle>UTF8 Encoded</subtitle><icon>icon.png</icon></item><item uid="HTML Encoded" arg="&uuml; &ouml; &auml;" valid="yes" autocomplete=""><title>&uuml; &ouml; &auml;</title><subtitle>HTML Encoded</subtitle><icon>icon.png</icon></item><item uid="base64 Encoded" arg="w7wgw7Ygw6Q=" valid="yes" autocomplete=""><title>w7wgw7Ygw6Q=</title><subtitle>base64 Encoded</subtitle><icon>icon.png</icon></item></items>

```

 

Looks like the workflow is sending the properly encoded values, for some reason alfred is running into an error on that row. I'm not sure what the issue is.

Link to comment

I don't pretend to know why (PHP is not my thing), but this test:
 

if ($html_encode != $query)

is failing within Alfred, so the HTML-encoded output isn't added to your $encodes array.

I changed the end of the encode script to:
 

$result = $w->toxml();

file_put_contents('php://stderr', $result);

echo $result;

to verify in the debugger. No idea why, but when run within Alfred, this is the XML output:
 

<?xml version="1.0"?>
<items><item uid="URL Encoded" arg="u%CC%88+a%CC%88" valid="yes" autocomplete=""><title>u%CC%88+a%CC%88</title><subtitle>URL Encoded</subtitle><icon>icon.png</icon></item><item uid="UTF8 Encoded" arg="uÌ aÌ" valid="yes" autocomplete=""><title>uÌ aÌ</title><subtitle>UTF8 Encoded</subtitle><icon>icon.png</icon></item><item uid="base64 Encoded" arg="dcyIIGHMiA==" valid="yes" autocomplete=""><title>dcyIIGHMiA==</title><subtitle>base64 Encoded</subtitle><icon>icon.png</icon></item></items>

But on the command line, this is the output:

<?xml version="1.0"?>
<items><item uid="URL Encoded" arg="%C3%BC+%C3%A4" valid="yes" autocomplete=""><title>%C3%BC+%C3%A4</title><subtitle>URL Encoded</subtitle><icon>icon.png</icon></item><item uid="UTF8 Encoded" arg="ü ä" valid="yes" autocomplete=""><title>ü ä</title><subtitle>UTF8 Encoded</subtitle><icon>icon.png</icon></item><item uid="HTML Encoded" arg="&uuml; &auml;" valid="yes" autocomplete=""><title>&uuml; &auml;</title><subtitle>HTML Encoded</subtitle><icon>icon.png</icon></item><item uid="base64 Encoded" arg="w7wgw6Q=" valid="yes" autocomplete=""><title>w7wgw6Q=</title><subtitle>base64 Encoded</subtitle><icon>icon.png</icon></item></items>

Also, what's the intention of the UTF-8-encoded output? As far as I can tell, you're UTF-8 encoding text that is already UTF-8 encoded (the input), and nonsense is coming out:

OhwcTyW.png

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...