PHPackages                             p4bgroup/fix-utf8 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. p4bgroup/fix-utf8

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

p4bgroup/fix-utf8
=================

Fix garbled/multiple utf8 encodings applied to a string

2.0.0(2y ago)11.6k↓100%FreeBSD LicensePHPPHP ^8.2

Since Dec 21Pushed 2y ago4 watchersCompare

[ Source](https://github.com/P4BGroup/fix-utf8)[ Packagist](https://packagist.org/packages/p4bgroup/fix-utf8)[ Docs](https://github.com/P4BGroup/fix-utf8)[ RSS](/packages/p4bgroup-fix-utf8/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

FixUTF8
=======

[](#fixutf8)

Fix garbled/multiple utf8 encodings applied to a string

Description
-----------

[](#description)

If you apply PHP utf8\_encode() multiple times to a string it will result in a garbled string.

Often times there might be cases when first portion of the string is encoded twice and other parts are encoded multiple times.

```
$garbledString = utf8_encode('Für ') . utf8_encode(utf8_encode('Straße'));
$garbledString = utf8_encode($garbledString);
```

Requirements
------------

[](#requirements)

- PHP ^8.2

Usage
-----

[](#usage)

```
