Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 使用PHP或bash shell在ubuntu中将UTF-8转换为CP1252_Windows_Ubuntu_Encoding_Utf 8_Cp1252 - Fatal编程技术网

Windows 使用PHP或bash shell在ubuntu中将UTF-8转换为CP1252

Windows 使用PHP或bash shell在ubuntu中将UTF-8转换为CP1252,windows,ubuntu,encoding,utf-8,cp1252,Windows,Ubuntu,Encoding,Utf 8,Cp1252,我有一个关于在Ubuntu中用PHP或SHELL将UTF-8转换为CP1252的问题 背景:使用PHP或SHELL在Ubuntu中将csv文件从UTF-8转换为CP1252,将文件从Ubuntu复制到Windows,使用nodepad++打开文件 环境: Ubuntu 10.04 PHP5.3 带有字母(œ,á,ç)的csv文件 使用的方法: 使用PHP iconv(“UTF-8”、“CP1252”、“文件内容”) 或 mb\u convert\u编码(“文件内容”、“UTF-8”、“CP1

我有一个关于在Ubuntu中用PHP或SHELL将UTF-8转换为CP1252的问题

背景:使用PHP或SHELL在Ubuntu中将csv文件从UTF-8转换为CP1252,将文件从Ubuntu复制到Windows,使用nodepad++打开文件

环境:

  • Ubuntu 10.04
  • PHP5.3
  • 带有字母(œ,á,ç)的csv文件
使用的方法:

  • 使用PHP
    iconv(“UTF-8”、“CP1252”、“文件内容”)


    mb\u convert\u编码(“文件内容”、“UTF-8”、“CP1252”)

    如果我使用
    文件-文件的名称
    
    它显示:
    文件的名称:text/plain;字符集=iso-8859-1

    我将这个转换后的文件复制到windows并用notepad++打开,在右下角,我们可以看到编码是ANSI
    当我将编码从ANSI更改为Windows-1252时,特殊字符显示得很好

  • 带壳
    iconv-f UTF-8-t CP1252“文件内容”

    其余的都一样

  • 问题: 1.为什么命令文件没有直接显示CP1252或ANSI,而是显示ISO-8895-1? 2.当我将编码从ANSI更改为Windows-1252时,为什么可以很好地显示特殊字符

    提前谢谢你!

    1

    CP1252和ISO-8859-1非常相似,其中一个编码的文件通常看起来与第二个编码的文件相同。查看哪些字符在Windows-1252中,而不是在ISO-8859-1中

    字母
    a
    ç
    在两种编码中的编码相同。虽然ISO-8859-1没有
    œ
    和CP1252有,但
    文件
    可能遗漏了这一点。恐怕它不会分析整个文件

    二,

    “ANSI”是Windows中用于默认非Unicode编码的误称。对于西欧语言,ANSI表示Windows-1252。对于中欧语言,ANSI表示Windows-1250,对于俄语,ANSI表示Windows-1251,依此类推。除了Windows之外,没有任何东西使用术语“ANSI”来表示编码