Decodes UTF byte-order mark (BOM) into the encoding's name.

Paramètres

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.

Voir aussi

https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!Uni…

4 calls to advagg_get_encoding_from_bom()
advagg_file_get_contents dans ./advagg.module
Same as file_get_contents() but will convert string to UTF-8 if needed.
advagg_load_stylesheet_content dans ./advagg.module
Processes the contents of a stylesheet for aggregation.
advagg_pre_render_scripts dans ./advagg.module
Callback for pre_render to add elements needed for JavaScript to be rendered.
advagg_relocate_process_http_request dans advagg_relocate/advagg_relocate.advagg.inc
Get the TTL and fix UTF-8 encoding.

Fichier

./advagg.module, line 5158

Code

function advagg_get_encoding_from_bom($data) {
    static $bom_map = array(
        "" => 'UTF-8',
        "\xfe\xff" => 'UTF-16BE',
        "\xff\xfe" => 'UTF-16LE',
        "\x00\x00\xfe\xff" => 'UTF-32BE',
        "\xff\xfe\x00\x00" => 'UTF-32LE',
        "+/v8" => 'UTF-7',
        "+/v9" => 'UTF-7',
        "+/v+" => 'UTF-7',
        "+/v/" => 'UTF-7',
        "+/v8-" => 'UTF-7',
    );
    foreach ($bom_map as $bom => $encoding) {
        if (strpos($data, $bom) === 0) {
            return $encoding;
        }
    }
    return FALSE;
}