mbstring vs iconv

I was wondering today why use mbstring rather than iconv in Dokeos, and honestly I didn’t remember exactly why I had chosen mbstring in the past, but finding information about the *differences* between the two.

mbstring is a library that deals with multi-byte character strings

iconv is also a library that deals with multi-byte character strings

However, their respective documentation doesn’t mention the other one.

Searching a bit more, I found a PPT presentation from Carlos Hoyos on Google
saying this:

PHP supports multi byte in two extensions: iconvĀ  and mbstring
* iconv uses an external library (supports more encodings but less portable)
* mbstring has the library bundled with PHP (less encodings but more portable)

If that’s the case (I assume he’s right as he was giving that conference at NewYork PHP) then the choice I made a few years ago was the right one. We want maximum portability, so we’re going to continue using mbstring until there is a major reason not to.

Although asking for more info on the general PHP list (which has traffic of a few thousand mails per months), I only got one personal opinion answer, so I guess the difference is really boiling down to a few minor things (including the licence), making this article almost useless, or at least in the sense of comparing the libraries.

2 Responses to “mbstring vs iconv”

  1. Magento Partner Says:

    In Zend Framework and applications depending on it like Magento they prefer iconv instead of the old mbstring. Although I guess there are good reasons why Zend has choosen the “new” iconv lib, mbstring has still a lot more and helpful functions to offer.
    Perhaps Zend will rely on the libiconv in feature PHP releases - just think of mb support in PHP6….

  2. ywarnier Says:

    Interesting to know. I just sent a mail to php-general’s list to see if there’s someone there who knows more about actual benchmarks or anything useful in terms of comparison.

Leave a Reply