Skip to content

Commit

Permalink
Checking encoding out of Beta :) It can find any other encoding than …
Browse files Browse the repository at this point in the history
…UTF-8 BOM
  • Loading branch information
Saibamen committed Aug 17, 2015
1 parent a687fdf commit 31466ec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Features

- Find missing translation RC files
- Find missing translation strings (**WIP**)
- Find wrong encoded files

Installation
----------
Expand Down
17 changes: 13 additions & 4 deletions encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
include_once('header.php');
?>

<h1>Search for wrong encoded files (UTF-8 BOM)</h1>
<h1>Search for wrong encoded files</h1>

<div id="body">

Expand Down Expand Up @@ -133,11 +133,20 @@
if (!empty($isFile))
{
$text = file_get_contents($file[0]);
$first3 = substr($text, 0, 3);

if ($first3 === UTF8_BOM)
if (mb_check_encoding($text, 'UTF-8'))
{
echo 'Detected <b>UTF-8 BOM</b> in '. $file[0] .'<br>';
$first3 = substr($text, 0, 3);

if ($first3 === UTF8_BOM)
{
echo 'Detected <b>UTF-8 BOM</b> in '. $file[0] .'<br>';
$allWrongEnc++;
}
}
else
{
echo 'Detected <b>other encoding</b> in '. $file[0] .'<br>';
$allWrongEnc++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<ul class="nav navbar-nav">
<li><a href="index.php">Missing files</a></li>
<li><a href="diff.php">Missing strings (Beta)</a></li>
<li><a href="encoding.php">Check encoding (Beta)</a></li>
<li><a href="encoding.php">Check encoding</a></li>
</ul>
</div>
</div>
Expand Down

0 comments on commit 31466ec

Please sign in to comment.