You are here

function advagg_get_encoding_from_bom in Advanced CSS/JS Aggregation 7.2

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.

See also

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

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

File

./advagg.module, line 5157
Advanced CSS/JS aggregation module.

Code

function advagg_get_encoding_from_bom($data) {
  static $bom_map = array(
    "" => '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 ($bom_map as $bom => $encoding) {
    if (strpos($data, $bom) === 0) {
      return $encoding;
    }
  }
  return FALSE;
}