[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’=>’Y', ‘T’=>’B', ‘?’=>’Ss’, ‘à’=>’a', ‘á’=>’a', ‘a’=>’a', ‘?’=>’a', ‘?’=>’a', ‘?’=>’a', ‘?’=>’ae’, ‘?’=>’c', ‘è’=>’e', ‘é’=>’e', ‘ê’=>’e', ‘?’=>’e', ‘ì’=>’i', ‘í’=>’i', ‘?’=>’i', ‘?’=>’i', ‘e’=>’o', ‘?’=>’n', ‘ò’=>’o', ‘ó’=>’o', ‘?’=>’o', ‘?’=>’o', ‘?’=>’o', ‘?’=>’o', ‘ù’=>’u', ‘ú’=>’u', ‘?’=>’u', ‘y’=>’y', ‘y’=>’y', ‘t’=>’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', '?a'=>'e', '??'=>'e', '??'=>'i', '?-'=>'i', '??'=>'i', '?ˉ'=>'i', '?°'=>'o', '?±'=>'n', '?2'=>'o', '?3'=>'o', '?′'=>'o', '?μ'=>'o', '??'=>'o', '??'=>'o', '?1'=>'u', '?o'=>'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.