如何從文件的開頭刪除?我有一個(gè)CSS文件,當(dāng)我使用蓋迪特,但是當(dāng)PHP讀取它(將所有CSS文件合并為一個(gè))時(shí),這個(gè)CSS具有以下字符:PHP刪除了所有的空格,所以代碼中間的隨機(jī)代碼就會(huì)把整件事情搞砸。正如我提到的,當(dāng)我在Gedit中打開文件時(shí),實(shí)際上看不到這些字符,所以我不能很容易地刪除它們。我搜索了這個(gè)問(wèn)題,文件編碼顯然有問(wèn)題,這是有意義的,因?yàn)槲乙恢痹谕ㄟ^(guò)ftp和windows服務(wù)器將文件轉(zhuǎn)移到不同的Linux/Windows服務(wù)器。rsync,具有一系列文本編輯器。雖然我對(duì)字符編碼不太了解,所以我會(huì)很感激你的幫助。如果有幫助,文件將以UTF-8格式保存,Gedit不允許我將其保存為ISO-8859-15格式(文檔包含一個(gè)或多個(gè)不能使用指定字符編碼的字符)。我試著用Windows和Linux行尾保存它,但都沒(méi)有幫助。
3 回答

ibeautiful
TA貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊
$response = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $response);

開心每一天1111
TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超13個(gè)贊
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 關(guān)注
- 484 瀏覽
添加回答
舉報(bào)
0/150
提交
取消