1.2.76. Avoid mb_dectect_encoding()¶
mb_dectect_encoding() is bad at guessing encoding.
For example, UTF-8 and ISO-8859-1 share some common characters : when a string is build with them it is impossible to differentiate the actual encoding.
<?php
$encoding = mb_encoding_detect($_GET['name']);
?>
See also mb_encoding_detect, PHP vs. The Developer: Encoding Character Sets and DPC2019: Of representation and interpretation: A unified theory - Arnout Boks.
1.2.76.1. Connex PHP features¶
1.2.76.1.1. Suggestions¶
Store and transmit the data format
1.2.76.1.2. Specs¶
Short name |
Php/AvoidMbDectectEncoding |
Rulesets |
|
Exakat since |
1.8.9 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |