Skip to content

Commit

Permalink
Merge branch 'master' of github.com:neitanod/ForceUTF8
Browse files Browse the repository at this point in the history
  • Loading branch information
neitanod committed Oct 10, 2018
2 parents abf5082 + 75e3615 commit fa82e98
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ will output:
Fédération Camerounaise de Football
Fédération Camerounaise de Football
Fédération Camerounaise de Football

Options:
========
By default, `Encoding::fixUTF8` will use the `Encoding::WITHOUT_ICONV` flag, signalling that iconv should not be used to fix garbled UTF8 strings.

This class also provides options for iconv processing, such as `Encoding::ICONV_TRANSLIT` and `Encoding::ICONV_IGNORE` to enable these flags when the iconv class is utilized. The functionality of such flags are documented in the [PHP iconv documentation](http://php.net/manual/en/function.iconv.php).

Examples:

use \ForceUTF8\Encoding;

$str = "Fédération Camerounaise—de—Football\n"; // Uses U+2014 which is invalid
echo Encoding::fixUTF8($str); // Breaks invalid char (U+2014)
echo Encoding::fixUTF8($str, Encoding::ICONV_TRANSLIT);
echo Encoding::fixUTF8($str, Encoding::ICONV_TRANSLIT);

will output:

Fédération Camerounaise?de?Football
Fédération Camerounaise—de—Football
Fédération Camerounaise—de—Football

Install via composer:
=====================
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "neitanod/forceutf8",
"homepage": "https://github.com/neitanod/forceutf8",
"license": "BSD-3-Clause",
"type": "library",
"description": "PHP Class Encoding featuring popular Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strings.",
"require": {
Expand Down

0 comments on commit fa82e98

Please sign in to comment.