Skip to content

Commit 284aa72

Browse files
authored
Merge pull request #644 from MaSpeng/feature/624-php-8-1-compatibility
#624: Provide PHP 8.1 compatibility
2 parents d76d712 + b559fbb commit 284aa72

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/PhpImap/Mailbox.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,7 @@ public function hasImapStream(): bool
486486
*/
487487
public function encodeStringToUtf7Imap(string $str): string
488488
{
489-
$out = \mb_convert_encoding($str, 'UTF7-IMAP', \mb_detect_encoding($str, 'UTF-8, ISO-8859-1, ISO-8859-15', true));
490-
491-
if (!\is_string($out)) {
492-
throw new UnexpectedValueException('mb_convert_encoding($str, \'UTF-8\', {detected}) could not convert $str');
493-
}
494-
495-
return $out;
489+
return imap_utf7_encode($str);
496490
}
497491

498492
/**
@@ -502,7 +496,7 @@ public function encodeStringToUtf7Imap(string $str): string
502496
*/
503497
public function decodeStringFromUtf7ImapToUtf8(string $str): string
504498
{
505-
$out = \mb_convert_encoding($str, 'UTF-8', 'UTF7-IMAP');
499+
$out = imap_utf7_decode($str);
506500

507501
if (!\is_string($out)) {
508502
throw new UnexpectedValueException('mb_convert_encoding($str, \'UTF-8\', \'UTF7-IMAP\') could not convert $str');

0 commit comments

Comments
 (0)