<?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";
- Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- 3134 - UTF-16
3134 - UTF-16
4451 - UTF-16LE
4451 - UTF-16LE
- Output for 8.0.1 - 8.0.30
- 3134 - ASCII
3134 - UTF-8
4451 - ASCII
4451 - UTF-8
preferences:
72.31 ms | 407 KiB | 5 Q