[Plugin: Shortcode Exec PHP] Unicode Garbled
-
Before I start… thank you very much for a very, very useful plug-in. Not only has this simple framework allowed me to comfortably use shortcodes as a dabbling non-developer, but has also prompted me to learn and use PHP as I slowly replace a number of not-quite-right plug-ins with my own shortcode codes, and begin realizing the world of possibilities that come with custom fields. But I digress..
In order to use sort($array) on a set of strings with unusual characters, I borrowed and slightly modified a normalize() function from an online forum:
function normalize ($string) { $table = array( ‘Š’=>’S', ‘š’=>’s’, ‘?’=>’Dj’, ‘?’=>’dj’, ‘Ž’=>’Z', ‘ž’=>’z', ‘?’=>’C', ‘?’=>’c', ‘?’=>’C', ‘?’=>’c', ‘À’=>’A', ‘Á’=>’A', ‘Â’=>’A', ‘Ã’=>’A', ‘Ä’=>’A', ‘Å’=>’A', ‘Æ’=>’AE’, ‘Ç’=>’C', ‘È’=>’E', ‘É’=>’E', ‘Ê’=>’E', ‘Ë’=>’E', ‘Ì’=>’I', ‘Í’=>’I', ‘Î’=>’I', ‘Ï’=>’I', ‘Ñ’=>’N', ‘Ò’=>’O', ‘Ó’=>’O', ‘Ô’=>’O', ‘Õ’=>’O', ‘Ö’=>’O', ‘Ø’=>’O', ‘Ù’=>’U', ‘Ú’=>’U', ‘Û’=>’U', ‘Ü’=>’U', ‘Ý’=>’Y', ‘Þ’=>’B', ‘ß’=>’Ss’, ‘à’=>’a', ‘á’=>’a', ‘â’=>’a', ‘ã’=>’a', ‘ä’=>’a', ‘å’=>’a', ‘æ’=>’ae’, ‘ç’=>’c', ‘è’=>’e', ‘é’=>’e', ‘ê’=>’e', ‘ë’=>’e', ‘ì’=>’i', ‘í’=>’i', ‘î’=>’i', ‘ï’=>’i', ‘ð’=>’o', ‘ñ’=>’n', ‘ò’=>’o', ‘ó’=>’o', ‘ô’=>’o', ‘õ’=>’o', ‘ö’=>’o', ‘ø’=>’o', ‘ù’=>’u', ‘ú’=>’u', ‘û’=>’u', ‘ý’=>’y', ‘ý’=>’y', ‘þ’=>’b', ‘ÿ’=>’y', ‘?’=>’R', ‘?’=>’r', ‘(‘=>”, ‘)’=>”, ‘,’=>”, ‘/’=>”, ); return strtr($string, $table); }The shortcode works great, and does everything it should, until I go back to edit the code in the admin area, where it now looks like this:
function normalize ($string) { $table = array( 'Å '=>'S', 'Å¡'=>'s', '?'=>'Dj', '?'=>'dj', 'Ž'=>'Z', 'ž'=>'z', '?'=>'C', '?'=>'c', '?'=>'C', '?'=>'c', 'Ã�'=>'A', 'Ã�'=>'A', 'Ã�'=>'A', 'Ã�'=>'A', 'Ã�'=>'A', 'Ã�'=>'A', 'Ã�'=>'A', 'Ã�'=>'C', 'Ã�'=>'E', 'Ã�'=>'E', 'Ã�'=>'E', 'Ã�'=>'E', 'Ã�'=>'I', 'Ã�'=>'I', 'Ã�'=>'I', 'Ã�'=>'I', 'Ã�'=>'N', 'Ã�'=>'O', 'Ã�'=>'O', 'Ã�'=>'O', 'Ã�'=>'O', 'Ã�'=>'O', 'Ã�'=>'O', 'Ã�'=>'U', 'Ã�'=>'U', 'Ã�'=>'U', 'Ã�'=>'U', 'Ã�'=>'Y', 'Ã�'=>'B', 'Ã�'=>'Ss', 'à '=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'Ã¥'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'Ã'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y', '?'=>'R', '?'=>'r', '('=>'', ')'=>'', ','=>'', '/'=>'', ); return strtr($string, $table); }So each time I want to edit the code, I first need to replace the latter garble-y code with the former. Is there away to store and retrieve the code without the character-mapping issues?
The topic ‘[Plugin: Shortcode Exec PHP] Unicode Garbled’ is closed to new replies.