How can I encode and decode urls from IDN in php?

im make a website for verification, registration, etc. domains, I have to make it compatible with IDN. Right now I have something like this:

echo $domain;       
$domain = idn_to_ascii($domain);
echo $domain;
$domain = idn_to_utf8($domain);
echo $domain;

and im get the following:

testing123ásd123 x - testing123sd123-WJB testing123ĂĄsd123

since you can see that the decoded string does not match the original, I also tried using the http://phlymail.com/en/downloads/idna/download/ class to do this and im getting the same results

I tried using:

$charset="UTF-8";
echo $domain;       
$domain = idn_to_ascii($domain, $charset);
echo $domain;
$domain = idn_to_utf8($domain);
echo $domain;

and I got exactly the same (except that the encoded string is slightly different)

any ideas?

EDIT: ! ( PHP, phlyLabs punycode string converter) iso-8859-2 UTF-8, , iso-8859-2 , google . - ? ? , ? ?

+3
1

, ĂĄ UTF8 á, , UTF8.

iconv() . , , Unicode, , HTML. :.

<?php

$domain = idn_to_utf8($domain);
echo htmlentities($domain, ENT_COMPAT, 'UTF-8');

?>

UTF-8 .

+3

Source: https://habr.com/ru/post/1754062/


All Articles