| 1 | <?php |
||
| 5 | class StringUtil |
||
| 6 | { |
||
| 7 | const BOM_UTF8 = "\xEF\xBB\xBF"; |
||
| 8 | const BOM_UTF16_BE = "\xFE\xFF"; |
||
| 9 | const BOM_UTF16_LE = "\xFF\xFE"; |
||
| 10 | const BOM_UTF32_BE = "\x00\x00\xFE\xFF"; |
||
| 11 | const BOM_UTF32_LE = "\xFF\xFE\x00\x00"; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Returns whether the given string starts with a UTF-8 Byte Order Mark. |
||
| 15 | * |
||
| 16 | * @param string $input |
||
| 17 | * |
||
| 18 | * @return bool |
||
| 19 | */ |
||
| 20 | 2 | public static function hasBom($input, $bom) |
|
| 24 | |||
| 25 | /** |
||
| 26 | * Strips the UTF-8 Byte Order Mark from the beginning of a string |
||
| 27 | * if it is present. |
||
| 28 | * |
||
| 29 | * @param string $input Data to be stripped of its BOM. |
||
| 30 | * |
||
| 31 | * @return string The stripped input string. |
||
| 32 | */ |
||
| 33 | 1 | public static function stripBom($input, $bom) |
|
| 41 | } |
||
| 42 |