-
I'm wondering why some of the functions manually quote meta characters in the regex rather than using preg_quote()?
//quote charlist for use in a characterclass
$charlist = preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$charlist);.
2009-10-30 19:01:52 UTC by xeoncross
-
After going through this library it seems like it would be easiest to add this code to existing projects by checking for and overriding the mb_* functions as needed. For example, you could do something like this:
if ( extension_loaded('mbstring') == FALSE ) {
include('utf8.php');
}
which would contain all the matching string functions (called utf8_*) defined as mb_* functions for a...
2009-10-30 18:47:43 UTC by xeoncross
-
agree!
2009-01-14 13:56:07 UTC by nobody
-
agree!
2009-01-14 13:55:34 UTC by nobody
-
What do you think about using function mb_check_encoding to check utf8 string? i.e.:
function utf8_is_valid($str) {
if (function_exists('mb_check_encoding')) {
return mb_check_encoding($str, 'UTF-8');
}
...
2008-03-13 09:12:58 UTC by aprisobal
-
In utf8_to_ascii (x00.php), the opening square bracket (U+005B) is not properly mapped to itself. That is, the array value directly following 'Z' should be '[' and not ']'.
2007-11-06 17:30:23 UTC by nobody
-
function utf8_sprintf($format) {
$argv = func_get_args();
array_shift($argv);
return utf8_vprintf($format, $argv);
}
function utf8_vprintf($format, $arguments) {
if (mb_internal_encoding() != 'UTF-8') {
return vsprintf($format, $arguments);
}
$newargv = array();
preg_match_all("`\%('.+|[0 ]|)([1-9][0-9]*|)s`U", $format, $results, PREG_SET_ORDER);
if (count($results)) {.
2007-09-29 09:41:36 UTC by aprisobal
-
The function is not by me.
/**
* Wordwrap for utf8 encoded strings
* @param string $str
* @param integer $len
* @param string $what
* @return string
* @author Milian Wolff
*/
function utf8_wordwrap($str, $width, $break=" ", $cut = false){
if(!$cut){
$regexp = '#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$width.',}\b#U';
} else {
$regexp =...
2007-09-29 09:39:29 UTC by aprisobal
-
Original author can be found here: (akniep at rayo dot info) http://www.php.net/manual/en/function.html-entity-decode.php
function utf8_html_entity_decode($string) {
static $trans_tbl;
// replace numeric entities
$string = preg_replace('~([0-9a-f]+);~ei', 'code2utf(hexdec("\\1"))', $string);
$string = preg_replace('~([0-9]+);~e', 'code2utf(\\1)', $string);
// replace...
2007-08-28 08:49:11 UTC by kingsquare
-
Finally fixed it and included in release 0.5.
2007-08-12 01:44:57 UTC by harryf