New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing mbstring dependency #541
Conversation
The dependency to mbstring in php7 could be removed with a fallback to strlen.
Could you provide a source for that? According to the documentation your change is wrong:
|
How about using https://github.com/symfony/polyfill-mbstring? |
You are right. I was too careless and didn't see the differences in the results. I did a little more research on this and the code could be like this:
This way it will fallback from non-default extension to default extension to core extension. As stated in a comment to iconv_strlen, it will fail with badly formatted sequences. Because of this i had to silence iconv_strlen. With non of the solutions i get the expected results on bad sequences. To test bad sequences i used this: http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt All in all, the code is not pretty but it works as it should. |
There's some discussion in #561, but to sum it up: Seeing as how all alternative implementations use extensions themselves, there isn't really a way to implement a fallback without depending on at least one extension. Even if relying on a default extension, we should still declare this dependence (as default extensions can be disabled), so we might as well just depend on the extension that does what we need directly. And if people want to install polyfills that depend on other extensions, then they can still do that with the added knowledge of which extensions they have available. Hope that all makes sense :) |
Just one small addition: If you're developing a end-user application with Parsedown, and if you don't want to require your users to install {
"require": {
"erusev/parsedown": "^1.7.1",
"symfony/polyfill-mbstring": "^1.7"
},
"config": {
"platform": { "ext-mbstring": "7" }
}
} However, please be warned that this isn't recommended (quite the contrary). You should rather tell your users to install |
The dependency to mbstring in php7 could be removed with a fallback to strlen.