Skip to content

Instantly share code, notes, and snippets.

@divinity76
Last active October 10, 2019 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divinity76/be63893d4e81c0b6b6851c197acf40f1 to your computer and use it in GitHub Desktop.
Save divinity76/be63893d4e81c0b6b6851c197acf40f1 to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
function guess_encoding(string $str): string {
if($str===''){throw new \InvalidArgumentException('input string empty!');}
$blacklist = array (
'pass',
'auto',
'wchar',
'byte2be',
'byte2le',
'byte4be',
'byte4le',
'BASE64',
'UUENCODE',
'HTML-ENTITIES',
'7bit',
'8bit',
'Quoted-Printable',
);
$encodings = array_diff ( mb_list_encodings (),$blacklist );
$detected = mb_detect_encoding ( $str, $encodings, true );
return ( string ) $detected;
}
@divinity76
Copy link
Author

this is almost certainly UTF16 but is being identifier as UTF8...
hex2bin("570069006e0064006f00770073002000530075006200730079007300740065006d00200066006f00720020004c0069006e0075007800200044006900730074007200690062007500740069006f006e0073003a000d000d000a005500620075006e00740075002d00310036002e003000340020002800440065006600610075006c00740029000d000d000a00");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment