Skip to content

Commit

Permalink
Use mb_detect_encoding with $strict = true
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Oct 27, 2015
1 parent 2d58871 commit e6c89f1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Expand Up @@ -160,7 +160,7 @@ public function testLogUTF8LongString()
$dbalLogger
->expects($this->once())
->method('log')
->with('SQL', array('short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, mb_detect_encoding($longString)).' [...]'))
->with('SQL', array('short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]'))
;

$dbalLogger->startQuery('SQL', array(
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Application.php
Expand Up @@ -1089,7 +1089,7 @@ private function stringWidth($string)
return strlen($string);
}

if (false === $encoding = mb_detect_encoding($string)) {
if (false === $encoding = mb_detect_encoding($string, null, true)) {
return strlen($string);
}

Expand All @@ -1106,7 +1106,7 @@ private function splitStringByWidth($string, $width)
return str_split($string, $width);
}

if (false === $encoding = mb_detect_encoding($string)) {
if (false === $encoding = mb_detect_encoding($string, null, true)) {
return str_split($string, $width);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Helper/Helper.php
Expand Up @@ -53,7 +53,7 @@ protected function strlen($string)
return strlen($string);
}

if (false === $encoding = mb_detect_encoding($string)) {
if (false === $encoding = mb_detect_encoding($string, null, true)) {
return strlen($string);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Helper/TableHelper.php
Expand Up @@ -386,7 +386,7 @@ private function renderCell(array $row, $column, $cellFormat)
$width = $this->getColumnWidth($column);

// str_pad won't work properly with multi-byte strings, we need to fix the padding
if (function_exists('mb_strwidth') && false !== $encoding = mb_detect_encoding($cell)) {
if (function_exists('mb_strwidth') && false !== $encoding = mb_detect_encoding($cell, null, true)) {
$width += strlen($cell) - mb_strwidth($cell, $encoding);
}

Expand Down
Expand Up @@ -132,7 +132,7 @@ public function reverseTransform($value)
throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like');
}

if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($value)) {
if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($value, null, true)) {
$length = mb_strlen($value, $encoding);
$remainder = mb_substr($value, $position, $length, $encoding);
} else {
Expand Down

0 comments on commit e6c89f1

Please sign in to comment.