Forums

Multi-column Tag Map
My solution to the utf8 problem (14 posts)

  1. Birgir Erlendsson
    Member
    Posted 7 months ago #

    Here is my solution to fix the utf8 problem:

    Instead of the line:

    $first_letter = $tag->name[0];

    I use this:

    $first_letter = mb_strtoupper( mb_substr($tag->name,0,1) );

    http://wordpress.org/extend/plugins/multi-column-tag-map/

  2. Birgir Erlendsson
    Member
    Posted 7 months ago #

    ps: the above changes is for line 302 in mctagmap.php

  3. tugbucket
    Member
    Posted 7 months ago #

    Birgir,

    Can you please post a link to a page that this is working on? My solution so far has quite a few more lines of code behind it.

    Thanks

  4. Birgir Erlendsson
    Member
    Posted 7 months ago #

    Hi, I use the shortcode

    [mctagmap columns="4" more="meira &amp#187;" hide="no" num_show="4" toggle="«" show_empty="no" name_divider="|" tag_count="yes"]

    on this new Icelandic webpage: http://60plus.is/stikkord/

    and this works well for the Icelandic characters (for example: Á, Æ)

  5. tugbucket
    Member
    Posted 7 months ago #

    Interesting. Can you do me one more favor? Can you make a sample tag that begins with Þ so I can see if it renders that correctly?

  6. Birgir Erlendsson
    Member
    Posted 7 months ago #

    ok, done, reload

  7. Birgir Erlendsson
    Member
    Posted 7 months ago #

    Have now tested (Á, Æ, Þ, Â, ß, ç) and its seems to work OK

  8. Birgir Erlendsson
    Member
    Posted 7 months ago #

    ... and tried some Chinese symbols (汉,語) - they work as well

  9. tugbucket
    Member
    Posted 7 months ago #

    awesome, thanks.

    I'll use that in the update. It's a lot simpler than what I was working on.

  10. Birgir Erlendsson
    Member
    Posted 7 months ago #

    At least it is working for the basic shortcode version
    in WP version 3.2.1 with PHP5.

    I just uploaded the plugin today, so I haven't tested all the features ;-)

    The PHP must also have a support for multibyte string functions:

    - http://www.php.net/manual/en/mbstring.supported-encodings.php
    - http://www.php.net/manual/en/book.mbstring.php

    ps: thanks for your nice plugin

  11. tugbucket
    Member
    Posted 7 months ago #

    Yeah, I was testing this:

    $first_letter = ucfirst(mb_convert_encoding(htmlentities($tag->name, ENT_NOQUOTES, 'UTF-8'), "ISO-8859-15", "UTF-8"));

    but, it didn't handle Þ and Cyrillic so I was using more lines to determine what letter it was trying to be.

    So for locally your simpler way is working.

    I'm working on another addition as well and when I get that done, I'll release a new one.

    Thanks again

    p.s. sorting by language is going to be tougher. That's for later ;)

  12. Birgir Erlendsson
    Member
    Posted 7 months ago #

    Here is my fix/hack to get the right language order:

    Instead of the line

    ksort($groups);

    one could use

    if(strlen(WPLANG)>0){
       setlocale(LC_COLLATE,WPLANG'.UTF-8');
    }
    uksort($groups,'strcoll');

    where I'm using the language-option in wp-config.php

    define ('WPLANG', 'is_IS');

    to figure out what kind of encoding the user wants ;-)

    This hack is working for my setup.

  13. Birgir Erlendsson
    Member
    Posted 7 months ago #

    missing dot:

    setlocale(LC_COLLATE,WPLANG.'.UTF-8');

  14. Birgir Erlendsson
    Member
    Posted 7 months ago #

    Maybe it is better to put it above the loops and preserve the current locale:

    $current_locale=setlocale(LC_COLLATE, '0');
    if(strlen(WPLANG)>0){
       setlocale(LC_COLLATE,WPLANG.'.UTF-8');
    }

    and the after the loops:

    setlocale(LC_COLLATE,$current_locale);

    cheers ;-)

Reply

You must log in to post.

About this Plugin

About this Topic