mbstring, a proposition of additional functions

From: Date: Mon, 06 Aug 2012 19:54:35 +0000
Subject: mbstring, a proposition of additional functions
Groups: php.internals 
Request: Send a blank email to internals+get-62072@lists.php.net to get a copy of this message
Hello, ext/mbstring is very useful, but from my point of view, some functions are missing. I would like to propose the addition of the following functions. mb_append($str, $piece) and mb_prepend($str, $piece): To add a $piece to, respectively, the end and the start of $string. It should consider the text direction, e.g. if $str is Right-to-Left, mb_append() will add $piece to the end, so the left, of $string. concat($str, $piece): If mb_append() and mb_prepend() are too hard to understand by users, concat() would be pretty much simpler and will act in the same way. mb_pad($length, $piece, $end): Pretty much like strpad but with multi-bytes considering. Note that, like mb_append and mb_prepend, we do not speak about left and right, but start and end. mb_get_direction($str): Return LTR or RTL. For one char, it is “easy”. For a string, it is more complex because we can have embedding directions (a string with many directions). mb_get_char($code) or mb_chr($code): Get Unicode character from a code-point/decimal value representation. mb_get_code($char) or mb_ord($char): Get code-point/decimal value representation from of Unicode character. Finally, it would be great if mb_substr() could consider text direction (or create a new dedicated function?). For example, mb_substr($str, 0, 1) will return the first char from the start (and not the left as it is implemented now). I think it could help developers to create nice libraries without requiring a lot of skills in Unicode. Thoughts? Best regards :-). -- Ivan Enderlin Developer of Hoa http://hoa.42/ or http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/

« previous php.internals (#62072) next »