linux curl save as utf-8

后端 未结 2 671
栀梦
栀梦 2021-01-04 06:18

Trying to use linux curl to download an xml file from an url.

Pretty sure that the xml is encoded in UTF-8,

suspecting curl -o doesnt save as UTF-8.

2条回答
  •  日久生厌
    2021-01-04 07:10

    curl does not do any conversion of the file it downloads. If the HTTP server serves you the XML in another encoding (e.g., ISO8859-1) that his how curl will save it to disk too.

    To workaround your problem, you can use "iconv" as follows:

    curl URL | iconv -f iso8859-1 -t utf-8 > output.xml
    

    Hope this help.

提交回复
热议问题