Skip to content

Instantly share code, notes, and snippets.

@makryl
makryl / gist:9092213
Last active February 23, 2020 22:30
file_get_contents with detect any UTF or one specified 8-bit encoding (default Windows-1251)
<?php
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');
@poppen
poppen / menu.lst
Created July 23, 2012 03:01
menu.lst of grub4dos for booting iso images from usb drive
# This is a sample menu.lst file. You should make some changes to it.
# The old install method of booting via the stage-files has been removed.
# Please install GRLDR boot strap code to MBR with the bootlace.com
# utility under DOS/Win9x or Linux.
color white/light-blue yellow/cyan light-gray/magenta white/light-red
title Acronis True Image Home
find --set-root /atih.iso
map /atih.iso (0xff) || map --mem /atih.iso (0xff)