|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52348 Ability to detect zend multibyte mode at runtime
Submitted: 2010-07-15 17:31 UTC Modified: 2010-11-25 15:55 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: php-bugs at thequod dot de Assigned: kalle
Status: Closed Package: PHP options/info functions
PHP Version: 5.3.3RC3 OS:
Private report: No CVE-ID:
 [2010-07-15 17:31 UTC] php-bugs at thequod dot de
I could not find (useful) documentation for the "enable-zend-multibyte" configure option.

It is mentioned to be a requirement for declare(encoding) [1], but
a) apparently the Windows builds do not have it enabled (according to phpinfo output
b) I cannot see how this can get detected on runtime (e.g. via some defined function) - I need to know if declare(encoding) processing is being done or not (and convert source files manually if declare(encoding) is ignored).



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-23 15:19 UTC]
Automatic comment from SVN on behalf of kalle
Log: Added remark about zend-multibyte mode, that its only exposed by phpinfo() (Bug #52348)
 [2010-10-23 15:19 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-10-23 15:19 UTC]
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:
	$zend_multibyte = false;


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

	unset($buffer, $pos);


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.
 [2010-10-23 17:46 UTC] 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 19:14 UTC]
-Summary: Please document --enable-zend-multibyte configure option +Summary: Ability to detect zend multibyte mode at runtime -Status: Closed +Status: Re-Opened -Type: Documentation Problem +Type: Feature/Change Request -Package: Documentation problem +Package: PHP options/info functions
 [2010-10-23 19:14 UTC]
Done, I can add such a constant to the 5.3 branch and trunk sometime this weekend
 [2010-11-11 02:43 UTC]
Automatic comment from SVN on behalf of kalle
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-11-11 02:44 UTC]
-Status: Re-Opened +Status: Closed
 [2010-11-11 02:44 UTC]
Added, this will be available in PHP 5.3.4+ ;-)
 [2010-11-11 18:19 UTC] php-bugs at thequod dot de
Thanks a lot!
 [2010-11-25 15:55 UTC]
Someone on internals requested I added this here:

«The problem in 5.3 is not as grave as the bug report paints it, you don't need to sniff phpinfo() to see whether PHP was compiled with --enable-zend-multibyte. You can use, for instance:
key_exists("detect_unicode", ini_get_all())»
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 08:01:34 2015 UTC