ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Codeigniter 1.7.2 UTF-8 Edition

December 21, 2009 10:41am

Subscribe [15]
  • #1 / Dec 21, 2009 10:41am

    Sbioko

    382 posts

    Finally, you don’t need to wait for an implementation of UTF-8 in CI 2.0! Just unzip this package into your system folder! Make sure, that you made a backup of all your files. I’m not responsible for any consequences of using this package!

    Here is the link

    UPD: Oops, I forgot! You must replace your index.php too! This is important!

    UPD2: Please, someone, test it on PHP 4. I have tested it only on PHP 5.3.0! Thank you.

  • #2 / Dec 22, 2009 10:54am

    Sbioko

    382 posts

    Nobody needs this?

  • #3 / Dec 22, 2009 5:31pm

    Thanks Demedes! I’m new to CodeIgniter, but I believe that this will be very useful to me!

    Cheers,
    Bojan

  • #4 / Dec 22, 2009 6:13pm

    Johan André

    412 posts

    Nobody needs this?

    Not really, no!
    Does it change ANY files in the system-folder?

  • #5 / Dec 23, 2009 9:47am

    Sbioko

    382 posts

    Thanks Demedes! I’m new to CodeIgniter, but I believe that this will be very useful to me!

    Thank you for a good reply! Good luck in coding! If you will have any questions about it, just send me a PM!

    This package changes all system files and index.php too!

  • #6 / Dec 23, 2009 10:27am

    Phil Sturgeon

    2889 posts

    I’m behind a restrictive proxy so I cannot download, but I am still intrigued. What have you actually done here? I have been using CodeIgniter to work with UTF-8 strings and never come across any problems.

  • #7 / Dec 23, 2009 10:50am

    Sbioko

    382 posts

    In this package I implemented full UTF-8 support using the phputf8 library. A few weeks ago, I did something like in your tutorial, but with cyrilical symbols, it doesn’t work! So, I decided to develop Codeigniter UTF-8 Edition. I’m very proud of this 😊

    UPD: If you need this, I can upload this package to any file uploading service you want!

  • #8 / Dec 23, 2009 10:57am

    Phil Sturgeon

    2889 posts

    It works fine with mbstring and I would rather install a package than download an unofficial copy of CodeIgniter.

    Your special version of CodeIgniter is using this phputf8 package, and you have replaced EVERY string function with these functions?

  • #9 / Dec 23, 2009 12:37pm

    Sbioko

    382 posts

    Your special version of CodeIgniter is using this phputf8 package, and you have replaced EVERY string function with these functions?

    Yes.

    It works fine with mbstring and I would rather install a package than download an unofficial copy of CodeIgniter.

    It will be work fine only with mbstring and with mbstring’s functions overload.

  • #10 / Dec 23, 2009 6:09pm

    coolgeek

    45 posts

    I’m behind a restrictive proxy so I cannot download, but I am still intrigued. What have you actually done here? I have been using CodeIgniter to work with UTF-8 strings and never come across any problems.

    Phil - I just tried to post this on your blog, but I think I had trouble with your captcha.

    You wrote (and others have written similarly) “CodeIgniter by default is set to use UTF-8 for much of its internal functionality”.  Yet, in the process of refactoring an app that I’m readying for production, I’ve noticed that the CI code itself does not seem to use the mb_ string functions.  For example, substr() is used 112 times, but mb_substr() is not used at all.

    I’m new to l10n/i18n, so perhaps I am confused by your pointers to mb_ references.  Were they just for background, or do I in fact need to use the mb_functions?  If the latter, why isn’t the CI code using them?

    Also, what are your thoughts on this:

    http://hash-bang.net/2009/02/utf8-with-codeigniter/

    Is this unnecessary with CI and MySQL configured as you have laid out on your blog? Or is this useful in addition to your directions?  Or can this be used in lieu of the mb_ functions?

    Thanks

  • #11 / Dec 24, 2009 6:24am

    Phil Sturgeon

    2889 posts

    Several of CodeIgniter’s libraries do use the Multi-byte functions but only if they exist. E.g:

    // Set the character encoding in MB.
            if (function_exists('mb_internal_encoding'))
            {
                mb_internal_encoding($this->CI->config->item('charset'));
            }

    You are right Demedes, CodeIgniter probably could do with using them a little more, but as I said I have never really had an issue with UTF-8 characters in PyroCMS.

    For example, I wouldn’t expect a Cyrillic character to pass a-z (alpha in Form_validation) out of the box, because it is NOT abcdefghijklmnopqrstuvwyz and that to me seems fine.

    Where have you guys been having your UTF-8 troubles? It is very possible I am just missing something.

  • #12 / Dec 24, 2009 7:28am

    Sbioko

    382 posts

    Ok, I’ll give an example. Here you are:

    //Some method in controller
    function test()
    {
        echo strlen('тест');
    }

    This will output 8 without my package, and 4 with right UTF-8 support(you must replace strlen to utf8_strlen).

  • #13 / Dec 24, 2009 7:58am

    Phil Sturgeon

    2889 posts

    Well this is not core CodeIgniter code is it, so why could you not use mb_strlen? If you need to write a UTF-8 app and do lots of string work, installing MB functions is a fairly simple requirement.

    You suggested you had to re-write the core of CodeIgniter to get it working properly, this is only controller work…

  • #14 / Dec 24, 2009 8:38am

    Sbioko

    382 posts

    Yes, but as I saw, many of CI native libraries use, for example, trim or substr. If I will send them a non-english(for example, again) parameter, I will get unnormal symbols.

    My package fixes all this problems. What are you want to discuss?

  • #15 / Dec 24, 2009 8:48am

    Phil Sturgeon

    2889 posts

    Well I said where is it causing problems, and your demo was in a controller. Where is it actually causing problems? Validation, routing, text helpers, what? 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases