note 77860 deleted from function.urlencode by bjori

From: Date: Mon, 17 Sep 2007 12:59:50 +0000
Subject: note 77860 deleted from function.urlencode by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-130554@lists.php.net to get a copy of this message
Note Submitter: marc at neto dot com Reason: bad code ---- Like "ahrensberg at gmail dot com" earlier has writen, you can have problems with encode strings with special characters to flash. <?php function flash_encode($string) { $string = rawurlencode(utf8_encode($string)); $string = str_replace("%C2%96", "-", $string); $string = str_replace("%C2%91", "%27", $string); $string = str_replace("%C2%92", "%27", $string); $string = str_replace("%C2%82", "%27", $string); $string = str_replace("%C2%93", "%22", $string); $string = str_replace("%C2%94", "%22", $string); $string = str_replace("%C2%84", "%22", $string); $string = str_replace("%C2%8B", "%C2%AB", $string); $string = str_replace("%C2%9B", "%C2%BB", $string); return $string; } ?> Add 3 more lines, and it works correct for me: <?php function flash_encode($string) { $string = rawurlencode(utf8_encode($string)); $string = str_replace("%C2%96", "-", $string); $string = str_replace("%C2%91", "%27", $string); $string = str_replace("%C2%92", "%27", $string); $string = str_replace("%C2%82", "%27", $string); $string = str_replace("%C2%93", "%22", $string); $string = str_replace("%C2%94", "%22", $string); $string = str_replace("%C2%84", "%22", $string); $string = str_replace("%C2%8B", "%C2%AB", $string); $string = str_replace("%C2%9B", "%C2%BB", $string); $string = str_replace("83%C2%", "", $string); $string = str_replace("C3%83-", "C3%96", $string); $string = str_replace("%C3%83%22", "%C3%84", $string); return $string; } ?>

« previous php.notes (#130554) next »