Created
October 7, 2014 18:30
-
-
Save vvasabi/b011cb997f30da1dd247 to your computer and use it in GitHub Desktop.
Remove Photoshop gremlins. Use it like so: pbpaste | php antigremlin.php | pbcopy.
This file contains hidden or 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 | |
function remove_gremlins($str) { | |
$cleaned = ''; | |
for ($i = 0, $max = strlen($str); $i < $max; $i++) { | |
$char_str = substr($str, $i, 1); | |
$char = ord($char_str); | |
if (($char >= 32) || ($char == 13)) { // new line or printable chars | |
$cleaned .= $char_str; | |
} | |
} | |
return $cleaned; | |
} | |
while($buffer = fgets(STDIN)){ | |
echo remove_gremlins($buffer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment