Can stash convert a curl document to utf-8?
I am trying to fetch a json document that has utf-16 accented vowels and convert it to utf-8 on the output file. I have a command line in the format:
curl "url" -H "X-API-Key: key-goes-here" -o outfile.json
I can't figure out where to add something like ' .encode(utf-8)' on the command line in order to convert to utf-8. Some say this kind of command line could solve the problem:
curl URL | iconv -f iso8859-1 -t utf-8 > output.xml
But stash curl does not accept iconv , -f, or -t arguments. Is there a way to make this work in stash?
sounds like a good improvement to curl, or create a new iconv command! see stash/bin and go to town!
I thought of a workaround which is superior for my purposes. Redirect the downloaded file to the console:
curl "url" -H "X-API-Key: key-goes-here" > &3
Where it can be copied and pasted to a new file. If can be then read like this:
with open('outfile.json, 'r',encoding='UTF-8') as f:
This has the real advantage of preserving all of the accented vowels, etc. in the rest of the data processing. It turns out the original file was indeed UTF-8, but could not be handled by the ASCII decoder.