Created
June 4, 2014 09:54
-
-
Save baptistedonaux/cb8e890c6e0fba5b694a to your computer and use it in GitHub Desktop.
Delete invisible ASCII chars which can generate errors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
gc_disable(); | |
$content = file_get_contents("db.csv"); | |
if ($content === false) { | |
echo "ERROR: impossible to read the file."; | |
die(); | |
} | |
for($i = 0; $i < strlen($content); $i++) { | |
$ascii = ord($content[$i]); | |
if (($ascii < 32 or $ascii > 126) and $ascii != 10) { | |
$content[$i] = "?"; | |
} | |
} | |
if (file_put_contents("new.csv", $content) === false) { | |
echo "ERROR: impossible to write the new file."; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment