如何从文件的开头删除?我有一个CSS文件,当我使用盖迪特,但是当PHP读取它(将所有CSS文件合并为一个)时,这个CSS具有以下字符:PHP删除了所有的空格,所以代码中间的随机代码就会把整件事情搞砸。正如我提到的,当我在Gedit中打开文件时,实际上看不到这些字符,所以我不能很容易地删除它们。我搜索了这个问题,文件编码显然有问题,这是有意义的,因为我一直在通过ftp和windows服务器将文件转移到不同的Linux/Windows服务器。rsync,具有一系列文本编辑器。虽然我对字符编码不太了解,所以我会很感激你的帮助。如果有帮助,文件将以UTF-8格式保存,Gedit不允许我将其保存为ISO-8859-15格式(文档包含一个或多个不能使用指定字符编码的字符)。我试着用Windows和Linux行尾保存它,但都没有帮助。
3 回答
ibeautiful
TA贡献1993条经验 获得超5个赞
$response = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $response);
开心每一天1111
TA贡献1836条经验 获得超13个赞
awk
mb_internal_encoding()
<?php //Storing the previous encoding in case you have some other piece //of code sensitive to encoding and counting on the default value. $previous_encoding = mb_internal_encoding(); //Set the encoding to UTF-8, so when reading files it ignores the BOM mb_internal_encoding('UTF-8'); //Process the CSS files... //Finally, return to the previous encoding mb_internal_encoding($previous_encoding); //Rest of the code... ?>
- 3 回答
- 0 关注
- 461 浏览
添加回答
举报
0/150
提交
取消