Posts: 409
Threads: 24
Joined: Oct 2014
Reputation:
18
A few times over the time I have worked with CodeIgniter on projects that involves East languages (chinese and japanese) ...
In most of the time there were no issues related to those languages but at a few cases where I had to make some "strange things", there were some problems related to using mb_ and not mb_ string functions at the framework.
So for CI 4 instead of default using both mb_substr or substr I want to suggest making a class to do all the work.
It can be 1class only (I think this is enough) or it can be Abstract class (with all required methods) + Childs (Multibyte / Normal / other..) where 1 of the childs will be autoloaded using the config.
Posts: 1,591
Threads: 1
Joined: Oct 2014
Reputation:
121
And that class would do ... what?
Posts: 409
Threads: 24
Joined: Oct 2014
Reputation:
18
09-09-2015, 01:32 AM
(This post was last modified: 09-09-2015, 02:22 AM by sv3tli0.)
Simple CI will use it at all places where string methods are required.
Developers from their hands will be able to Switch between Normal Strings methods, multibytes or whatever they want .
By this the Framework will be some steps more Open for the developers.
If for some reasons dev's don't want to use mb_ or they want to use only mb_ , they will be able just to switch between does 2 ..
If some one wants he can make even a mix where some of the methods are mb_ some are not mb_ and some are entirely custom written methods..
+ Such library can be and extended to provide some extra methods to developers in 1 place.
My believe is that 1 good Framework should provide options to devs, not to force them.
P.S. This will remove PHP extension dependency of the framework (MB) and at the same time will support it.
I don't know how will work exactly the autoloader and other things at CI 4, but such class can have both : static and none static method support.
So $CI->string can be preloaded and at the same time clients can call it using its namespace/Class::method()
Posts: 644
Threads: 13
Joined: Oct 2014
Reputation:
37
09-10-2015, 03:19 PM
(This post was last modified: 09-10-2015, 03:40 PM by ivantcholakov.
Edit Reason: a typo
)
@sv3tli0
It could be done with autodetection, the class could check for mb_string (faster, but less supported encoding), iconv (slower, more supported encodings), intl (I think, it has multibyte routines too, but they are likely not well documented). If none exists, then fallback PHP implementation (by method) could be done. For every method the best possible way can be picked up automatically.