Supported Versions: PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8
Convert a string from one character encoding to another
<?php mb_convert_encoding(array|string $string, string $to_encoding, array|string|null $from_encoding = null): array|string|false
<?php {
$failed_at = Date::now();
$exception = (string) mb_convert_encoding($exception, 'UTF-8');
return $this->getTable()->insertGetId(compact(
'connection', 'queue', 'payload', 'exception', 'failed_at'
<?php 'connection' => $connection,
'queue' => $queue,
'payload' => $payload,
'exception' => (string) mb_convert_encoding($exception, 'UTF-8'),
'failed_at' => Date::now(),
]);
<?php 'connection' => $connection,
'queue' => $queue,
'payload' => $payload,
'exception' => (string) mb_convert_encoding($exception, 'UTF-8'),
'failed_at' => $failedAt->format('Y-m-d H:i:s'),
'failed_at_timestamp' => $failedAt->getTimestamp(),
]);
<?php $uuid = Str::uuid();
$exception = new Exception(mb_convert_encoding('ÐÑÙ0E\xE2\x�98\xA0World��7B¹!þÿ', 'ISO-8859-1', 'UTF-8'));
$provider = new DatabaseFailedJobProvider($db->getDatabaseManager(), 'default', 'failed_jobs');
$provider->log('database', 'default', json_encode(['uuid' => (string) $uuid]), $exception);
<?php $provider->log('database', 'default', json_encode(['uuid' => (string) $uuid]), $exception);
$exception = (string) mb_convert_encoding($exception, 'UTF-8');
$this->assertSame(1, $db->getConnection()->table('failed_jobs')->count());
$this->assertSame($exception, $db->getConnection()->table('failed_jobs')->first()->exception);
<?php 'connection' => 'connection',
'queue' => 'queue',
'payload' => json_encode(['uuid' => $uuid]),
'exception' => (string) mb_convert_encoding($exception, 'UTF-8'),
'failed_at' => $failedJobs[0]->failed_at,
'failed_at_timestamp' => $failedJobs[0]->failed_at_timestamp,
],
<?php 'connection' => 'connection',
'queue' => 'queue',
'payload' => json_encode(['uuid' => $uuidTwo]),
'exception' => (string) mb_convert_encoding($exceptionTwo, 'UTF-8'),
'failed_at' => $failedJobs[1]->failed_at,
'failed_at_timestamp' => $failedJobs[1]->failed_at_timestamp,
],
<?php 'connection' => 'connection',
'queue' => 'queue',
'payload' => json_encode(['uuid' => $uuidOne]),
'exception' => (string) mb_convert_encoding($exceptionOne, 'UTF-8'),
'failed_at' => $failedJobs[0]->failed_at,
'failed_at_timestamp' => $failedJobs[0]->failed_at_timestamp,
],
<?php 'connection' => 'connection',
'queue' => 'queue',
'payload' => json_encode(['uuid' => (string) $uuid]),
'exception' => (string) mb_convert_encoding($exception, 'UTF-8'),
'failed_at' => $failedJob->failed_at,
'failed_at_timestamp' => $failedJob->failed_at_timestamp,
], $failedJob);
<?php public function testEWithInvalidCodePoints()
{
$str = mb_convert_encoding('føø bar', 'ISO-8859-1', 'UTF-8');
$this->assertEquals('f�� bar', e($str));
}