Answer the question
In order to leave comments, you need to log in
How to convert utf-8 letter to html code (A -> А)?
There is a character base in the html code.
There is a need to compare the input character with the character code from the database.
How can this be implemented?
// Это не отрабатывает как ожидается
echo htmlsprcialchars(htmlentity('A')); //А
Answer the question
In order to leave comments, you need to log in
function encode($str) {
$str = mb_convert_encoding($str , 'UTF-32', 'UTF-8');
$split = str_split($str, 4);
$res = "";
foreach ($split as $c) {
$cur = 0;
for ($i = 0; $i < 4; $i++) {
$cur |= ord($c[$i]) << (8*(3 - $i));
}
$res .= "&#" . $cur . ";";
}
return $res;
}
var_dump(encode('t'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question