mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
* API: support for mbstring.func_overload=0 (previously we required mbstring.func_overload=7 to correctly support utf-8)
This commit is contained in:
parent
4cce17070f
commit
7082a10338
@ -2149,9 +2149,9 @@ class etemplate extends boetemplate
|
||||
{
|
||||
self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
|
||||
}
|
||||
if ((int) $attr['maxlength'] > 0 && strlen($value) > (int) $attr['maxlength'])
|
||||
if ((int) $attr['maxlength'] > 0 && mb_strlen($value) > (int) $attr['maxlength'])
|
||||
{
|
||||
$value = substr($value,0,(int) $attr['maxlength']);
|
||||
$value = mb_substr($value,0,(int) $attr['maxlength']);
|
||||
}
|
||||
if ($attr['preg'] && !preg_match($attr['preg'],$value))
|
||||
{
|
||||
|
@ -1465,9 +1465,9 @@ class egw_db
|
||||
}
|
||||
// only truncate string if length given and <= 255
|
||||
// to not unnecessary truncate varchar(>255) as PostgreSQL uses text anyway and MySQL truncates itself silently (unless strict mode!)
|
||||
if (!is_null($length) && $length <= 255 && strlen($value) > $length)
|
||||
if (!is_null($length) && $length <= 255 && mb_strlen($value) > $length)
|
||||
{
|
||||
$value = substr($value,0,$length);
|
||||
$value = mb_substr($value, 0, $length);
|
||||
}
|
||||
// casting boolean explicitly to string, as ADODB_postgres64::qstr() has an unwanted special handling
|
||||
// for boolean types, causing it to return "true" or "false" and not a quoted string like "'1'"!
|
||||
|
@ -65,9 +65,39 @@ function cut_bytes(&$data,$offset,$len=null)
|
||||
|
||||
if (is_null($len))
|
||||
{
|
||||
return $func_overload ? mb_substr($data,$offset,bytes($data),'ascii') : substr($data,$offset);
|
||||
return $func_overload & 2 ? mb_substr($data,$offset,bytes($data),'ascii') : substr($data,$offset);
|
||||
}
|
||||
return $func_overload & 2 ? mb_substr($data,$offset,$len,'ascii') : substr($data,$offset,$len);
|
||||
}
|
||||
|
||||
if (!function_exists('mb_strlen'))
|
||||
{
|
||||
/**
|
||||
* Number of characters in a string
|
||||
*
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
function mb_strlen($str)
|
||||
{
|
||||
return strlen($str);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mb_substr'))
|
||||
{
|
||||
/**
|
||||
* Return part of a string
|
||||
*
|
||||
* @param string $data
|
||||
* @param int $offset
|
||||
* @param int $len
|
||||
* @return string
|
||||
*/
|
||||
function mb_substr(&$data, $offset, $len=null)
|
||||
{
|
||||
return is_null($len) ? substr($data, $offset) : substr($data, $offset, $len);
|
||||
}
|
||||
return $func_overload ? mb_substr($data,$offset,$len,'ascii') : substr($data,$offset,$len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user