Skip to content

Commit

Permalink
Reorder ByteSequence constants from longest to shortest. Fix thephple…
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwebservices committed Dec 3, 2019
1 parent b546ec0 commit cfb4473
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/ByteSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@
interface ByteSequence
{
/**
* UTF-8 BOM sequence.
* UTF-32 BE BOM sequence.
*/
const BOM_UTF8 = "\xEF\xBB\xBF";
const BOM_UTF32_BE = "\x00\x00\xFE\xFF";

/**
* UTF-16 BE BOM sequence.
* UTF-32 LE BOM sequence.
*/
const BOM_UTF16_BE = "\xFE\xFF";
const BOM_UTF32_LE = "\xFF\xFE\x00\x00";

/**
* UTF-16 LE BOM sequence.
* UTF-8 BOM sequence.
*/
const BOM_UTF16_LE = "\xFF\xFE";
const BOM_UTF8 = "\xEF\xBB\xBF";

/**
* UTF-32 BE BOM sequence.
* UTF-16 BE BOM sequence.
*/
const BOM_UTF32_BE = "\x00\x00\xFE\xFF";
const BOM_UTF16_BE = "\xFE\xFF";

/**
* UTF-32 LE BOM sequence.
* UTF-16 LE BOM sequence.
*/
const BOM_UTF32_LE = "\xFF\xFE\x00\x00";
const BOM_UTF16_LE = "\xFF\xFE";
}
4 changes: 4 additions & 0 deletions tests/ByteSequenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public function ByteSequenceMatchProvider(): array
'sequence' => 'The quick brown fox '.ByteSequence::BOM_UTF8.' jumps over the lazy dog',
'expected' => '',
],
'UTF-32 LE BOM sequence' => [
'sequence' => chr(255).chr(254).chr(0).chr(0),
'expected' => ByteSequence::BOM_UTF32_LE,
],
];
}
}

0 comments on commit cfb4473

Please sign in to comment.