Using iconv to convert from UTF-16LE to UTF-8

前端 未结 2 534
猫巷女王i
猫巷女王i 2020-12-23 15:55

Hi I am trying to convert some log files from a Microsoft SQL server, but the files are encoded using UTf-16LE and iconv does not seem to be able to convert them.

I

2条回答
  •  离开以前
    2020-12-23 16:31

    The command you specified will output to stdout. You can either use the -o parameter, or redirect your output:

    with -o:

    iconv -f UTF-16LE -t UTF-8 infile -o outfile
    

    with piping:

    iconv -f UTF-16LE -t UTF-8 infile > outfile
    

    Both will yield the desired result.

    However some versions of iconv (v1 on macOS for example) do not support the -o parameter and you will see that the converted text is echoed to stdout. In that case, use the piping option.

提交回复
热议问题