WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Shortcode Exec PHP] Unicode Garbled (3 posts)

  1. taxihorn
    Member
    Posted 4 years ago #

    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?

    http://wordpress.org/extend/plugins/shortcode-exec-php/

  2. Marcel Bokhorst
    Member
    Posted 4 years ago #

    Thanks for reporting this.
    Your problem should be fixed in version 1.1.
    Please let me know if it is or not.

  3. taxihorn
    Member
    Posted 4 years ago #

    Fixed! Awesome! Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic