public static function Unicode::encodingFromBOM in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Component/Utility/Unicode.php \Drupal\Component\Utility\Unicode::encodingFromBOM()
Decodes UTF byte-order mark (BOM) into the encoding's name.
Parameters
string $data: The data possibly containing a BOM. This can be the entire contents of a file, or just a fragment containing at least the first five bytes.
Return value
string|bool The name of the encoding, or FALSE if no byte order mark was present.
2 calls to Unicode::encodingFromBOM()
- CssOptimizer::loadFile in core/
lib/ Drupal/ Core/ Asset/ CssOptimizer.php - Loads the stylesheet and resolves all @import commands.
- JsOptimizer::optimize in core/
lib/ Drupal/ Core/ Asset/ JsOptimizer.php - Optimizes an asset.
File
- core/
lib/ Drupal/ Component/ Utility/ Unicode.php, line 180
Class
- Unicode
- Provides Unicode-related conversions and operations.
Namespace
Drupal\Component\UtilityCode
public static function encodingFromBOM($data) {
static $bomMap = [
"" => 'UTF-8',
"" => 'UTF-16BE',
"" => 'UTF-16LE',
"" => 'UTF-32BE',
"" => 'UTF-32LE',
"+/v8" => 'UTF-7',
"+/v9" => 'UTF-7',
"+/v+" => 'UTF-7',
"+/v/" => 'UTF-7',
"+/v8-" => 'UTF-7',
];
foreach ($bomMap as $bom => $encoding) {
if (strpos($data, $bom) === 0) {
return $encoding;
}
}
return FALSE;
}