Convert UTF-16 to UTF-8 under Windows and Linux, in C

前端 未结 8 705
不思量自难忘°
不思量自难忘° 2020-12-01 02:50

I was wondering if there is a recommended \'cross\' Windows and Linux method for the purpose of converting strings from UTF-16LE to UTF-8? or one should use different method

相关标签:
8条回答
  • 2020-12-01 03:39

    If you have MSYS2 installed then the iconv package (which is installed by default) lets you use:

     iconv -f utf-16le -t utf-8 <input.txt >output.txt
    
    0 讨论(0)
  • 2020-12-01 03:43

    Change encoding to UTF-8 with PowerShell:

    powershell -Command "Get-Content PATH\temp.txt -Encoding Unicode | Set-Content -Encoding UTF8 PATH2\temp.txt"
    
    0 讨论(0)
提交回复
热议问题