update another idnaconvert related class
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -80,7 +80,7 @@ class UnicodeTranscoder implements UnicodeTranscoderInterface
|
|||||||
|
|
||||||
$output = [];
|
$output = [];
|
||||||
$out_len = 0;
|
$out_len = 0;
|
||||||
$inp_len = strlen($input);
|
$inp_len = self::byteLength($input);
|
||||||
$mode = 'next';
|
$mode = 'next';
|
||||||
$test = 'none';
|
$test = 'none';
|
||||||
for ($k = 0; $k < $inp_len; ++$k) {
|
for ($k = 0; $k < $inp_len; ++$k) {
|
||||||
@@ -200,7 +200,7 @@ class UnicodeTranscoder implements UnicodeTranscoderInterface
|
|||||||
{
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
$out_len = 0;
|
$out_len = 0;
|
||||||
$inp_len = strlen($input);
|
$inp_len = self::byteLength($input);
|
||||||
$mode = 'd';
|
$mode = 'd';
|
||||||
$b64 = '';
|
$b64 = '';
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ class UnicodeTranscoder implements UnicodeTranscoderInterface
|
|||||||
{
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
|
|
||||||
$inp_len = strlen($input);
|
$inp_len = self::byteLength($input);
|
||||||
// Input length must be dividable by 4
|
// Input length must be dividable by 4
|
||||||
if ($inp_len % 4) {
|
if ($inp_len % 4) {
|
||||||
throw new \InvalidArgumentException('Input UCS4 string is broken');
|
throw new \InvalidArgumentException('Input UCS4 string is broken');
|
||||||
@@ -340,4 +340,19 @@ class UnicodeTranscoder implements UnicodeTranscoderInterface
|
|||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the length of a string in bytes even if mbstring function
|
||||||
|
* overloading is turned on
|
||||||
|
*
|
||||||
|
* @param string $string the string for which to get the length.
|
||||||
|
* @return integer the length of the string in bytes.
|
||||||
|
*/
|
||||||
|
protected static function byteLength($string)
|
||||||
|
{
|
||||||
|
if ((extension_loaded('mbstring') && (ini_get('mbstring.func_overload') & 0x02) === 0x02)) {
|
||||||
|
return mb_strlen($string, '8bit');
|
||||||
|
}
|
||||||
|
return strlen((binary) $string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user