Skip to content

Commit 70575e6

Browse files
committed
2 parents d96a5f8 + ccf0c86 commit 70575e6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Encoding.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Encoding
1616
public function encodeFile($file, $encoding_to = 'UTF-8', $encodings_detected = 'UTF-8,ISO-8859-1,WINDOWS-1252')
1717
{
1818
$encoding_original = $this->detectEncoding($file, $encodings_detected);
19-
19+
2020
if ($encoding_original !== false && $encoding_original != $encoding_to) {
2121
try {
2222
$fileW = $file.'.tmp';
@@ -27,6 +27,7 @@ public function encodeFile($file, $encoding_to = 'UTF-8', $encodings_detected =
2727
if (fwrite($handleW, mb_convert_encoding($line, $encoding_to, $encoding_original), 4096) === false) {
2828
fclose($handleR);
2929
fclose($handleW);
30+
3031
return false;
3132
}
3233
}
@@ -49,7 +50,7 @@ public function encodeFile($file, $encoding_to = 'UTF-8', $encodings_detected =
4950
/**
5051
* Detect file encoding.
5152
*
52-
* @param string $file Original file
53+
* @param string $file Original file
5354
* @param string $encodings_detected Ordered list of encodings
5455
*
5556
* @return mixed String encoding or false

tests/FileEncodingTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function test_encoding_iso88591_as_UTF8()
2727

2828
$this->assertTrue($encoding->detectEncoding(__DIR__.'/files/iso88591.txt', 'UTF-8,ISO-8859-1,WINDOWS-1252') == 'ISO-8859-1');
2929
$this->assertTrue($encoding->encodeFile(__DIR__.'/files/iso88591.txt', 'UTF-8', 'UTF-8,ISO-8859-1,WINDOWS-1252'));
30-
$this->assertTrue($encoding->checkEncoding(__DIR__.'/files/iso88591.txt','UTF-8'));
30+
$this->assertTrue($encoding->checkEncoding(__DIR__.'/files/iso88591.txt', 'UTF-8'));
3131

3232
$this->close();
3333
}
@@ -38,7 +38,7 @@ public function test_encoding_UTF8_as_UTF8()
3838
$encoding = new Encoding();
3939
$this->assertTrue($encoding->detectEncoding('tests/files/utf8.txt', 'UTF-8,ISO-8859-1,WINDOWS-1252') == 'UTF-8');
4040
$this->assertTrue($result = $encoding->encodeFile('tests/files/utf8.txt'));
41-
$this->assertTrue($encoding->checkEncoding('tests/files/utf8.txt','UTF-8'));
41+
$this->assertTrue($encoding->checkEncoding('tests/files/utf8.txt', 'UTF-8'));
4242

4343
$this->close();
4444
}
@@ -49,7 +49,7 @@ public function test_encoding_file_not_exists()
4949
$encoding = new Encoding();
5050
$this->assertFalse($encoding->detectEncoding('tests/files/test.txt', 'UTF-8,ISO-8859-1,WINDOWS-1252') == 'UTF-8');
5151
$this->assertFalse($result = $encoding->encodeFile('tests/files/test.txt'));
52-
$this->assertFalse($encoding->checkEncoding('tests/files/test.txt','UTF-8'));
52+
$this->assertFalse($encoding->checkEncoding('tests/files/test.txt', 'UTF-8'));
5353

5454
$this->close();
5555
}

0 commit comments

Comments
 (0)