$parent_base_path =
$basepath;
// Set the current base path to process possible child imports.
$basepath =
dirname($file);
// Load the CSS stylesheet. We suppress errors because themes may specify
// stylesheets in their .info.yml file that don't exist in the theme's path,
// but are merely there to disable certain module CSS files.
$content = '';
if ($contents = @
file_get_contents($file)) { // If a BOM is found, convert the file to UTF-8, then use substr() to
// remove the BOM from the result.
if ($encoding =
(Unicode::
encodingFromBOM($contents))) { $contents =
mb_substr(Unicode::
convertToUtf8($contents,
$encoding), 1
);
} // If no BOM, check for fallback encoding. Per CSS spec the regex is very strict.
elseif (preg_match('/^@charset "([^"]+)";/',
$contents,
$matches)) { if ($matches[1
] !== 'utf-8' &&
$matches[1
] !== 'UTF-8'
) { $contents =
substr($contents,
strlen($matches[0
]));
$contents = Unicode::
convertToUtf8($contents,
$matches[1
]);
} } // Return the processed stylesheet.