You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.
This library is orthogonal to mbstring.func_overload and will not work if the php.ini setting is enabled.
This library does not overload the standard string functions right? I also read on some posts on StackOverflow that overloading the string functions may have bad consequences when using third party libraries that use the string functions for binary operations and hence expect the normal string functions. http://evertpot.com/mbstring-function-overloading-dont-use-it/
If that's the case, let's assume I'm building a library that is intended to be used with other projects that will do some string manipulation. It's purpose is not string manipulation and hence I don't want to force an extension like mb_string.
How should I go about using functions like strlen()? Should I test for if the function mb_strlen() exists, and use it, or if it doesn't exist, use the basic strlen()?
The text was updated successfully, but these errors were encountered:
You're right, this lib doesn't override any PHP function.
What this article says is true, mbstring overloading is a nightmare.
You have several possibilities to work around if you want to make your own code work under such condition:
explicitly use mb_strlen($str, '8bit') like suggested in the article
use iconv instead of mbstring as this is included by default with PHP: iconv_strlen($str, 'CP1252') <= CP1252/ISO-8859-* is handled the same way as binary string
"disable" mbstring overloading by setting mb_internal_encoding("8bit"); either globally (in the bootstrap of your application) ; or locally (see e.g. Symfony's Yaml parser).
I read on the Readme that:
This library does not overload the standard string functions right? I also read on some posts on StackOverflow that overloading the string functions may have bad consequences when using third party libraries that use the string functions for binary operations and hence expect the normal string functions. http://evertpot.com/mbstring-function-overloading-dont-use-it/
If that's the case, let's assume I'm building a library that is intended to be used with other projects that will do some string manipulation. It's purpose is not string manipulation and hence I don't want to force an extension like mb_string.
How should I go about using functions like
strlen()
? Should I test for if the functionmb_strlen()
exists, and use it, or if it doesn't exist, use the basicstrlen()
?The text was updated successfully, but these errors were encountered: