Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl command output has wrong encoding

Tags:

linux

bash

curl

when i execute

curl "http://weather.yahooapis.com/forecastrss?w=1225955&u=c" 

it returns me response with incorrect encoding:

khan@khan-P55A-UD3P:~$ curl "http://weather.yahooapis.com/forecastrss?w=1225955&u=c" 
���dž��ud@3��v(
����$j$��~����4(���Xy����wH�o�9<q��,�s\��e"�tA�\݌h�ʄ���
                                                             �����h��M���{���J=�m93W
                                                                                      �S�)�e�[sv,�҉eAKM�z{ǔ��g��:���*�����(n�m��&�Jꟈ��Mg�,yn?F�&��_��
ik6                                                                                                                                                      >��0�e&X��簺
sQ~�:�Z;*9�.a"ߕ|��EO[�5"�׫[�k�����1ӆ�n?}r1�u�d��Cڐ��X��`�NF�g!�c��W��G��1�o����Z��53<z`���.��w� s׃��ߖ+�vh��3yt�b}�9
�6�s3K
�W�  �0�هF@���>�X֥Qh�ʰv�BQ�R
ʮ�<�4;�ڊ2�8y� �g���6M(��]�|'�U@�ș�B
�8du!�&'�NOB��ț��3�K��fW��
                           \Rheg�=��F�R;�u�F�s9���&����,��|r��o�E۲�T��V$&�����uf\������v��Z~&�Au��{��ى"m�ʨ���U����2�8�#0F@'������
                                                                                                                                           l���R�XL��~A��̱���p��9��8�iH��nC�i4��^t;����۪���d�V�����7��=S&��2�u�#v~�L`�k���v�0
                            �[���"<���~�z��j,���X=�zmKD/|���(�p��M���⥁}_�!��GџC��2|�G��<ফe��nb"x ?�e�s��;���r;ﲃ�]�9"l��;�}�w�ٮjwR[�C����#O�
                                                                                                                                                      �������#a����s�km���$a�����\)�$�o��Ә�K��FR�*�ý�l�Z
            �
             &�`_�D�WӠ�>`T��0��| c��⿎K%��n:���~(�����.{��}< /~�^!A��$\���c�<�Á
"��k�_��t����t�n�5�^t�وF��l<V�����oo?
                                        `O���3p��ĝ�S�X�G�x��Ź+�
khan@khan-P55A-UD3P:~$ 

However, the same command works just fine in another computer. is there anything i need to be setting in shell in order to get this in correct format ?

i m using ubuntu 14.04 64bits.(Linux khan-P55A-UD3P 3.13.0-40-generic #69-Ubuntu SMP Thu Nov 13 17:53:56 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux)

any ideas? a screenshot of the command can be seen here as well: http://i.imgur.com/QDy7F7i.png

like image 246
Shrouk Khan Avatar asked Nov 29 '14 08:11

Shrouk Khan


1 Answers

curl will automatically decompress the response if you set the --compressed flag:

curl --compressed "http://example.com"

--compressed (HTTP) Request a compressed response using one of the algorithms libcurl supports, and save the uncompressed document. If this option is used and the server sends an unsupported encoding, curl will report an error.

refrence of answer

if you need use this option only for gzip content encoding, use this command

curl -sH 'Accept-encoding: gzip' http://example.com/ | gunzip -
like image 117
mh-samiei Avatar answered Oct 28 '22 06:10

mh-samiei