Teo Posted April 5, 2014 Posted April 5, 2014 Hi Alfred users. I'm not completely sure this is a bug so I'm posting it here first. I have written a script that outputs xml which some times contains special characters. It seems that the xml interpreter in Alfred does not know what to do with those and aborts the whole script filter without any error in the debug log. A simple example would be: <?xml version="1.0" encoding="UTF-8"?><items><item arg="http://www.glossed.it/highlights" valid="YES" type="file"><title>title Ð</title><subtitle>test</subtitle><icon type="fileicon"></icon></item></items> I've coloured the offending character red. Without it the script filter works fine. Am I correct in thinking this is a bug in Alfred? Best regards, Teo
Tyler Eich Posted April 5, 2014 Posted April 5, 2014 No, this isn't a bug. Replace "Đ" with "Đ", the XML entity form of that character. I assume you generated this output manually (i.e. you didn't use a workflow helper library). You might consider using a workflow helper library that handles the XML generation and encoding for you
deanishe Posted April 5, 2014 Posted April 5, 2014 (edited) It will also work without using XML entities, but you have to actually encode the text to UTF-8 (which is what you've declared as the charset in the XML header). Nevertheless, as Tyler says, you're better off using a library to generate your XML for you. It's not entirely straightforward. Edited April 5, 2014 by deanishe
Carlos-Sz Posted April 6, 2014 Posted April 6, 2014 (edited) You can also try to use CDATA: <title><![CDATA[title Ð]]></title> Here is a sample using CDATA: Edited April 6, 2014 by Carlos-Sz
deanishe Posted April 6, 2014 Posted April 6, 2014 CDATA doesn't help if the encoding is wrong (Alfred won't display the result), which it is here because the posted XML is perfectly valid if properly encoded as UTF-8.
Teo Posted April 6, 2014 Author Posted April 6, 2014 Thank you everyone for your suggestions. Not knowing much about the xml I just ran the output through a few online xml verifier tools which all came back OK. I will have a deeper look now that I know the fault is on my side of things. Teo
deanishe Posted April 6, 2014 Posted April 6, 2014 Chances are your browser is correcting the encoding when you paste the text into the form field (browsers are very good at that). The best thing to do it what Tyler advised and use an XML generation library (or one of the workflow helper libraries) to produce your XML.
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