I have a question about converting UTF-8 to CP1252 in Ubuntu with PHP or SHELL.
Background : Converting a csv file from UTF-8 to CP1252 in Ubuntu with PHP or SHELL, copy file from Ubuntu to Windows, open file with nodepad++.
Environment :
- Ubuntu 10.04
- PHP 5.3
- a file csv with letters (œ, à, ç)
Methods used :
With PHP
iconv("UTF-8", "CP1252", "content of file")
ormb_convert_encoding("content of file", "UTF-8", "CP1252")
If I check the generated file withfile -i name_of_the_file
It displayed :name_of_the_file: text/plain; charset=iso-8859-1
I copy this converted file to windows and opened with notepad++, in the bottom of the right, we can see the encoding is ANSI
And when I changed the encoding from ANSI to Windows-1252, the specials characters were well displayed.With Shell
iconv -f UTF-8 -t CP1252" "content of file"
The rest will be the same .
Question : 1. Why the command file did not display directly CP1252 or ANSI but ISO-8895-1 ? 2. Why the specials characters could be well displayed when I changed the encoding from ANSI to Windows-1252.
Thank you in advance !