willfarrell Posted September 26, 2013 Posted September 26, 2013 Encoding and decoding a string into multiple variations. https://github.com/willfarrell/alfred-encode-decode-workflow
tobym Posted November 12, 2013 Posted November 12, 2013 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?
willfarrell Posted December 6, 2013 Author Posted December 6, 2013 Thanks @tobym,I looked into it. Turns out the base64 decoder was spitting out chars outside if it's alphabet, that broke the xml encoding. Update pushed to the github repo (v1.5).
Davide Posted February 16, 2014 Posted February 16, 2014 Thanks for this, but there is no html encoding for ü, ö, ä.
willfarrell Posted March 15, 2014 Author Posted March 15, 2014 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="ü ö ä" valid="yes" autocomplete=""><title>ü ö ä</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.
deanishe Posted March 17, 2014 Posted March 17, 2014 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="ü ä" valid="yes" autocomplete=""><title>ü ä</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:
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now