Edit report at http://bugs.php.net/bug.php?id=52348&edit=1

 ID:                 52348
 User updated by:    php-bugs at thequod dot de
 Reported by:        php-bugs at thequod dot de
 Summary:            Ability to detect zend multibyte mode at runtime
 Status:             Closed
 Type:               Feature/Change Request
 Package:            PHP options/info functions
 PHP Version:        5.3.3RC3
 Assigned To:        kalle
 Block user comment: N

 New Comment:

Thanks a lot!


Previous Comments:
------------------------------------------------------------------------
[2010-11-11 02:44:17] ka...@php.net

Added, this will be available in PHP 5.3.4+ ;-)

------------------------------------------------------------------------
[2010-11-11 02:43:55] ka...@php.net

Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=305266
Log: Added new constant; ZEND_MULTIBYTE to check whether PHP was
compiled using --enable-zend-multibyte or not instead of sniffing
phpinfo() (FR #52348)

------------------------------------------------------------------------
[2010-10-23 19:14:02] ka...@php.net

Done, I can add such a constant to the 5.3 branch and trunk sometime
this weekend

------------------------------------------------------------------------
[2010-10-23 17:46:17] php-bugs at thequod dot de

Thank you!



Can you forward / re-assign the bug maybe so that it is possible to
detect this during runtime, please?

Please leave a short reply, if you won't do it, so I will do this.

------------------------------------------------------------------------
[2010-10-23 15:19:57] ka...@php.net

Hi, sadly the multibyte mode isn't exposed, so the only way to check for
it is by sniffing phpinfo() which is really hacky. I wrote up a small
script for you to see what I mean by hacky:

<?php

        $zend_multibyte = false;



        ob_start();

        phpinfo(INFO_GENERAL);



        $buffer = ob_get_clean();

        $pos    = strpos($buffer, 'Zend Multibyte');

        $buffer = substr($buffer, $pos);



        if(PHP_SAPI == 'cli')

        {

                $buffer         = ltrim($buffer);

                $zend_multibyte = (trim(substr($buffer, 25, strpos($buffer, 
"\n") -
25)) == 'enabled');

        }

        else

        {

                $zend_multibyte = (trim(strip_tags(substr($buffer, 28, 
strpos($buffer,
"</tr>") - 28))) == 'enabled');

        }



        unset($buffer, $pos);



        var_dump($zend_multibyte);

?>



As for the documentation, I have added a note on the declare()
construct's page that its "impossible" to determine whether the build
have multibyte support or not.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=52348


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52348&edit=1

Reply via email to