问题
I am trying to convert the file generated from a mssql
to utf-8. When I open the output of he mssql
using notepad++ in windows server 2003 recognises the file as UCS-2LE
I copied the file to a Ubuntu machine, using file [file]
it shows that the encoding is UTF-16LE
.
Really confused, there must be some difference in encoding, as the names are different.
But why do I see this in the same file. Its a .csv
file generated from the mssql query.
回答1:
For the most part, UTF-16 and UCS-2 are the same thing. There is no difference.
What it means is that each character is two bytes wide. "LE" stands for little endian, i.e. each two-byte character is stored with the low byte first.
If you want to convert to UTF-8, in Notepad++ click Convert to UTF-8
in the Encoding menu, then save.
If your other programs choke on the file after doing this, or you see two garbage characters at the start of the file, then click Convert to UTF-8 without BOM
instead.
来源:https://stackoverflow.com/questions/11736096/notepad-shows-ucs-2le-while-ubuntu-file-file-shows-utf-16le-i-am-confused