Google Console Storage – Install Report (UTF-16LE)

function file_get_contents_utf_ansi($filename, $defAnsiEnc = ‘Windows-1251’) {
$buf = file_get_contents($filename);
if (substr($buf, 0, 3) == “\xEF\xBB\xBF”) return substr($buf,3);
else if (substr($buf, 0, 2) == “\xFE\xFF”) return mb_convert_encoding(substr($buf, 2), ‘UTF-8’, ‘UTF-16BE’);
else if (substr($buf, 0, 2) == “\xFF\xFE”) return mb_convert_encoding(substr($buf, 2), ‘UTF-8’, ‘UTF-16LE’);
else if (substr($buf, 0, 4) == “\x00\x00\xFE\xFF”) return mb_convert_encoding(substr($buf, 4), ‘UTF-8’, ‘UTF-32BE’);
else if (substr($buf, 0, 4) == “\xFF\xFE\x00\x00”) return mb_convert_encoding(substr($buf, 4), ‘UTF-8’, ‘UTF-32LE’);
else if (mb_detect_encoding(trim($buf), $defAnsiEnc) || utf8_encode(utf8_decode($buf)) != $buf) return mb_convert_encoding($buf, ‘UTF-8’, $defAnsiEnc);
else return $buf;
}

 

Got from stackoverflow

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.