Skip to content

Commit

Permalink
Remove deprecated utf8_encode in PHP 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mhcwebdesign authored and Progi1984 committed Sep 14, 2023
1 parent d1e7ed7 commit 4dce471
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/changes/1.x/1.2.0.md
Expand Up @@ -34,4 +34,5 @@
- Moved documention from ReadTheDocs to MkDocs & Github Pages by [@Progi1984](https://github.com/Progi1984) in GH-2465
- Bump phpstan/phpstan-phpunit from 1.3.13 to 1.3.14 by [@dependabot](https://github.com/dependabot) in [#2457](https://github.com/PHPOffice/PHPWord/pull/2457)
- Bump symfony/process from 5.4.26 to 5.4.28 by [@dependabot](https://github.com/dependabot) in [#2456](https://github.com/PHPOffice/PHPWord/pull/2456)
- Bump phpunit/phpunit from 9.6.10 to 9.6.11 by [@dependabot](https://github.com/dependabot) in [#2455](https://github.com/PHPOffice/PHPWord/pull/2455)
- Bump phpunit/phpunit from 9.6.10 to 9.6.11 by [@dependabot](https://github.com/dependabot) in [#2455](https://github.com/PHPOffice/PHPWord/pull/2455)
- Remove deprecated utf8_encode in PHP 8.2 by [@mhcwebdesign](https://github.com/mhcwebdesign) in [#2447](https://github.com/PHPOffice/PHPWord/pull/2447) & [#2472](https://github.com/PHPOffice/PHPWord/pull/2472)
2 changes: 1 addition & 1 deletion src/PhpWord/Shared/Text.php
Expand Up @@ -145,7 +145,7 @@ public static function isUTF8($value = '')
public static function toUTF8($value = '')
{
if (null !== $value && !self::isUTF8($value)) {
$value = utf8_encode($value);
$value = mb_convert_encoding($value, 'UTF-8', mb_list_encodings());
}

return $value;
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/TemplateProcessor.php
Expand Up @@ -257,7 +257,7 @@ protected static function ensureMacroCompleted($macro)
protected static function ensureUtf8Encoded($subject)
{
if (!Text::isUTF8($subject) && null !== $subject) {
$subject = utf8_encode($subject);
$subject = mb_convert_encoding($subject, 'UTF-8', mb_list_encodings());
}

return (null !== $subject) ? $subject : '';
Expand Down

0 comments on commit 4dce471

Please sign in to comment.