问题
When I run a csv parser on my windows machine, and redirect the output into a file, I always get doubled up line breaks when I open the file in OpenOffice Calc. Further, if I copy the contents of the file in notepad++, then save that as a new file using the default ANSI encoding, the file is half as big and line breaks display properly in Calc.
I'd prefer not to have to add a setting or header to every file I work on, since these scripts work fine on a linux install of PHP.
I assume that changing a setting in php.ini will fix this, but I don't know what it is and I haven't had much luck finding it. Does anyone know how to resolve this issue?
回答1:
There is an INI directive to change the character set sent by default in the Content-Type
header:
Per example:
default_charset = "iso-8859-1"
回答2:
Huh? You want to create a text file that opens correctly in both windows and linux?
Tough luck. Both operating system uses different ways to denote new lines. One uses a new line, where else the other ses a new line and a carrage return.
In Linux, there are programs called "dos2unix" and "unix2dos" that converts text for you between the windows and linux world. I think you will need to use that everytime you copy the files between the operating systems.
来源:https://stackoverflow.com/questions/7934041/xampp-setting-the-encoding-type-globally