<?php
$str1 = '14';
$str2 = 'DQ';
$encodings1 = ['ASCII', 'UTF-8', 'UTF-16', 'UTF-16LE'];
$encodings2 = ['UTF-8', 'UTF-16', 'UTF-16LE'];
echo bin2hex($str1) . ' - ' . mb_detect_encoding($str1, $encodings1, true)."\n";
echo bin2hex($str1) . ' - ' . mb_detect_encoding($str1, $encodings2, true)."\n";
echo bin2hex($str2) . ' - ' . mb_detect_encoding($str2, $encodings1, true)."\n";
echo bin2hex($str2) . ' - ' . mb_detect_encoding($str2, $encodings2, true)."\n";
preferences:
24.4 ms | 405 KiB | 5 Q