Last active
October 10, 2019 18:46
-
-
Save divinity76/be63893d4e81c0b6b6851c197acf40f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is almost certainly UTF16 but is being identifier as UTF8...
hex2bin("570069006e0064006f00770073002000530075006200730079007300740065006d00200066006f00720020004c0069006e0075007800200044006900730074007200690062007500740069006f006e0073003a000d000d000a005500620075006e00740075002d00310036002e003000340020002800440065006600610075006c00740029000d000d000a00");