3v4l.org

run code in 300+ PHP versions simultaneously
<?php $exclude = 'BASE64,UUENCODE,HTML-ENTITIES,Quoted-Printable,' . '7bit,8bit,pass,wchar,byte2be,byte2le,byte4be,byte4le,' . 'UCS-4,UCS-4BE,UCS-4LE,UCS-2,UCS-2BE,UCS-2LE'; $prio = [ 'UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', 'WINDOWS-1252', 'WINDOWS-1251', 'WINDOWS-1254', 'EUC-JP', 'EUC-TW', 'KOI8-R', 'BIG-5', 'ISO-2022-KR', 'ISO-2022-JP', 'GB18030', ]; $all_encodings = array_diff(mb_list_encodings(), explode(',', $exclude)); $encodings = array_unique(array_merge($prio, $all_encodings)); $test = 'Iksi' . chr(241) . 'ski'; echo mb_detect_encoding($test, $encodings);

preferences:
19.56 ms | 402 KiB | 5 Q