PHP Classes

PHP Convert UTF8 to Latin1 UTF8 Encoded: Convert latin characters that were double-encoded

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 130 This week: 1All time: 9,337 This week: 571Up
Version License PHP version Categories
php-utf8-decode-fren 1.0GNU General Publi...5PHP 5, Text processing
Description 

Author

This class can convert latin characters that were double-encoded.

It can take as parameter a string that has latin characters with accents and cedillas but were encoded twice as utf8.

The class replaces the double encoded latin characters with the correct characters in UTF-8.

It can also check if a string has a correct representation of text string in UTF-8.

Innovation Award
PHP Programming Innovation award winner
February 2021
Winner


Prize: SourceGuarding PHP encoder tool
Sometimes applications store text that was given by the application users using UTF-8 encoded.

However, due to programming mistakes, the application may encode the text again as UTF-8, when it was already encoded as UTF-8. This mistake is called double-encoding.

To fix the text that was double encoded, it it is necessary to revert the last step of encoding of the characters.

This class provides a solution, that not only can undo the double-encoding mistake, but it is also able to detect the encoding of a given text, so you can evaluate what encoding it is using.

Manuel Lemos
Picture of Hassane Moussa
  Performance   Level  
Name: Hassane Moussa <contact>
Classes: 10 packages by
Country: Niger Niger
Age: 40
All time rank: 21481 in Niger Niger
Week rank: 103 Up1 in Niger Niger Equal
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<?php
/***************************************************************************************
            Examples Using Class Utf8DecodeFrenchAccentsEncoded
***************************************************************************************/

 
require_once 'Utf8DecodeFrenchAccentsEncoded.php';


$classDecodeUtf8Fr = new Utf8DecodeFrenchAccentsEncoded();

$example1 ="PHPCLASSES est déjà le meilleur site.";

$example2 ="PHPCLASSES est déjà le meilleur site.";

$example3 ="PHPCLASSES est d&eacute;j&agrave; le meilleur site.";

$example4 ="PHPCLASSES est d0233j0225 le meilleur site.";

echo
"-------------------------------- <b>Before using Class Utf8DecodeFrenchAccentsEncoded</b> ---------------------------<br><br>";

echo
"<b>Example1</b> :: ".$example1."<br><br>";

echo
"<b>Example2</b> :: ".$example2."<br><br>";

echo
"<b>Example3</b> :: ".$example3."<br><br>";

echo
"<b>Example4</b> :: ".$example4."<br><br>";

echo
"-------------------------------- <b>After using Class Utf8DecodeFrenchAccentsEncoded</b> -----------------------------<br><br>";

echo
"<b>Example1 with preg_replace</b> :: ".$classDecodeUtf8Fr->fr_utf8_decode_with_preg_replace($example1)."<br><br>";

echo
"<b>Example1 with str_replace</b> :: ".$classDecodeUtf8Fr->fr_utf8_decode_str_replace($example1)."<br><br>";

echo
"<b>Example2</b> :: ".$classDecodeUtf8Fr->fr_utf8_decode_with_preg_replace($example2)."<br><br>";

echo
"<b>Example3</b> :: ".$classDecodeUtf8Fr->fr_utf8_decode_with_preg_replace($example3)."<br><br>";

echo
"<b>Example4</b> :: ".$classDecodeUtf8Fr->fr_utf8_decode_with_preg_replace($example4)."<br><br>";




Details

PHP-Utf8-Decode-French-Accents-Encoded

This PHP class can decode UTF8 encoded strings for French special characters.

It extends the Utf8DecodeFrenchAccentsEncoded PHP class to provide functions that can detects character encoding on a given string and can decode utf8 encoded Accents characters of French language.

The class functions take the string encoded as parameter to show the string decode in utf8. For is_utf8() function, it return a boolean.


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Image file screenshot.JPG Data Auxiliary data
Plain text file Utf8DecodeFrenchAccentsEncoded.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:130
This week:1
All time:9,337
This week:571Up