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

前端 未结 2 533
猫巷女王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.

    0 讨论(0)
  • 2020-12-23 16:44

    I forgot the -o switch!

    The final command is :

    iconv -f UTF-16LE -t UTF-8 <filename> -o <new-filename>
    
    0 讨论(0)
提交回复
热议问题