我有一个包含数千个产品说明的CSV文件,标题中包含®或™。
这导致我的导入器在到达这些符号时停止读取该行。
我需要删除它们或将它们更改为(TM),(R)等。
我有以下PHP文件替换文本但不适用于符号:
$fname = "/../var/www/vhosts/website.co.uk/httpdocs/folder/file.csv";
$fhandle = fopen($fname,"r");
$content = fread($fhandle,filesize($fname));
$content = str_replace("red", "yellow", $content); --------//This works!
$content = str_replace("®", "r", $content); -------//This doesnt!
$fhandle = fopen($fname,"w");
fwrite($fhandle,$content);
fclose($fhandle);
我使用过sed但没有运气。
sed 's/[™®]//g' /../var/www/vhosts/website.co.uk/httpdocs/folder/file.csv > /../var/www/vhosts/website.co.uk/httpdocs/folder/file.csv