php idn to ascii
idn_to_ascii() on PHP 7.2 #5300
Comments
ivantcholakov commented Oct 14, 2017
CodeIgniter 3.1.6, PHP 7.2.0RC3
The function idn_to_ascii() as is currently used throws the warning:
There are three places to be updated:
With the following snippet:
I tried this modification that seems to me ok:
The text was updated successfully, but these errors were encountered:
We are unable to convert the task to an issue at this time. Please try again.
The issue was successfully created but we are unable to update the comment at this time.
narfbg commented Oct 16, 2017
Thanks, I’ve pushed a patch for this.
udin-ordinary commented Feb 27, 2018
hello all,
for idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated
just add this in system/libraries/form_validation.php in line 1234
correct me any mistake.
its work for me with CI.3.1.7
narfbg commented Feb 28, 2018
CI 3.1.7 doesn’t have this issue; I don’t understand why you’re suggesting modifications at all.
udin-ordinary commented Mar 1, 2018
yes it does. iam facing that problem with CI 3.1.7 with PHP 7.2 on Xampp. so if any others face it that works for me.
many thanks for your reply.
narfbg commented Mar 1, 2018
Particularly on PHP 7.2 the only way to trigger that notice is if you have an ICU version lower than 4.6, at which point there’s literally nothing you can do about it.
datamweb commented Jul 29, 2018
@narfbg
This is also a problem for me.
PHP ver:7.2
CI ver: 1.3.9
wrabit commented Jul 30, 2018
Same here PHP 7.2 CI 3.1.8
vaultdweller123 commented Aug 9, 2018 •
why is this closed? this is not fixed. i got this error on my server but works on local weird!? fix pls! im not using this CI email validation at moment. id rather override this with my own email php validation or on js. this is no good
AG0001 commented Sep 12, 2018
vaultdweller123 commented Sep 12, 2018
that shit also error when you use their email library
narfbg commented Sep 13, 2018
That shit is the fault of whoever setup your servers with libicu versions from 10 years ago that nobody should be using anymore. And before talking shit, you should at least read the shit that I wrote.
I’ll repeat and simplify: this is impossible to fix! Literally. Not possible.
saadi09 commented Apr 10, 2019
I’m facing same issue its working fine on same version in localhost but when i place my project live on server it stuck with this error, kindly suggest me the best possible solution.
vaultdweller123 commented Apr 11, 2019 •
@saadi09 the solution i did was to override the CI core function to validate email. Go to system/libraries/Email.php and find the validate_email function and replace with this. you can also rename it for backup and paste this below it.
public function valid_email($email) <
return (bool) filter_var(trim($email), FILTER_VALIDATE_EMAIL);
>
saadi09 commented Apr 12, 2019
Thanks 🙂 it works pretty fine now although I’m using my own validation library rather than this one.
allayGerald commented Nov 15, 2019 •
for anyone still getting this for php >= 7.2 try checking if INTL_IDNA_VARIANT_UTS46 constant is defined
I added these lines on system/libraries/Email.php and system/libraries/Form_validation.php
raenk commented Feb 7, 2020 •
LIBICU version:
[root@one logs]# yum install libicu
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package libicu-50.2-3.el7.x86_64 already installed and latest version
Nothing to do
[root@one logs]#
CodeIgniter version:
const CI_VERSION = ‘3.1.11’;
I think I don’t meet the criteria for the diagnosis here. Am i missing anything?
narfbg commented Feb 11, 2020
raenk commented Feb 11, 2020
Thanks for your reply. I’ll look in that direction.
f4r424hm3d commented Jul 3, 2021 •
idn_to_ascii
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.2, PECL idn >= 0.1)
idn_to_ascii — Преобразовать доменное имя в формат IDNA ASCII
Описание
Эта функция преобразует доменное имя из Unicode в IDNA ASCII.
Список параметров
Имя для преобразования, должно быть в кодировке UTF-8.
INTL_IDNA_VARIANT_2003 (объявлена устаревшей начиная с PHP 7.2.0) для IDNA 2003 или INTL_IDNA_VARIANT_UTS46 (доступна только с ICU 4.6) для UTS #46.
Возвращаемые значения
Доменное имя в представлении ASCII или false в случае возникновения ошибки.
Список изменений
Примеры
Пример #1 Пример использования idn_to_ascii()
echo idn_to_ascii ( ‘täst.de’ );
Результат выполнения данного примера:
Смотрите также
User Contributed Notes 3 notes
The notes on this function are not very clear and a little misleading.
Firstly, =5.4 you will not require the PECL extensions.
Third, use of utf8_encode() is not necessary. In fact, it will potentially prevent idn_to_ascii() from working at all.
On my setup it was necessary to change the charset in the script meta tags to UTF-8:
The above changes mean that idn_to_ascii() can now be used with that syntax (no need for utf8_encode()). Previously, the function worked to convert some IDNs, but failed to convert Japanese and Cyrillic IDNs. Further, no additional locales were enabled or added, and Apache’s charset file was left unmodified.
It is also important to remember only to apply the function where required, eg:
idn_to_ascii(cåsino.com) // is wrong
iden_to_ascii(cåsino) // is right
I have found that Notepad++ easily and reliably handles UTF-8 encoding that works for this function using UTF-8 as the encoding option, not UTF-8 without BOM.
idn_to_ascii
(PHP 5 >= 5.3.0, PECL intl >= 1.0.2, PECL idn >= 0.1)
idn_to_ascii — Convert domain name to IDNA ASCII form.
Описание
This function converts Unicode domain name to IDNA ASCII-compatible format.
Список параметров
Domain to convert. In PHP 5 must be UTF-8 encoded.
Either INTL_IDNA_VARIANT_2003 for IDNA 2003 or INTL_IDNA_VARIANT_UTS46 for UTS #46.
Возвращаемые значения
Domain name encoded in ASCII-compatible form. или FALSE в случае возникновения ошибки
Список изменений
Версия | Описание |
---|---|
5.4.0/PECL 2.0.0b1 | Added the parameters variant and idna_info ; UTS #46 support. |
Примеры
Пример #1 idn_to_ascii() example
echo idn_to_ascii ( ‘täst.de’ );
Результат выполнения данного примера:
Смотрите также
Коментарии
The notes on this function are not very clear and a little misleading.
Firstly, =5.4 you will not require the PECL extensions.
Third, use of utf8_encode() is not necessary. In fact, it will potentially prevent idn_to_ascii() from working at all.
On my setup it was necessary to change the charset in the script meta tags to UTF-8:
The above changes mean that idn_to_ascii() can now be used with that syntax (no need for utf8_encode()). Previously, the function worked to convert some IDNs, but failed to convert Japanese and Cyrillic IDNs. Further, no additional locales were enabled or added, and Apache’s charset file was left unmodified.
It is also important to remember only to apply the function where required, eg:
idn_to_ascii(cåsino.com) // is wrong
iden_to_ascii(cåsino) // is right
I have found that Notepad++ easily and reliably handles UTF-8 encoding that works for this function using UTF-8 as the encoding option, not UTF-8 without BOM.
To convert IDN Domains with the IDNA2008 definition use following command.
idn_to_ascii
(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.2, PHP 7, PECL idn >= 0.1)
idn_to_ascii — Convert domain name to IDNA ASCII form.
Описание
This function converts Unicode domain name to IDNA ASCII-compatible format.
Список параметров
Domain to convert. In PHP 5 must be UTF-8 encoded.
Either INTL_IDNA_VARIANT_2003 for IDNA 2003 or INTL_IDNA_VARIANT_UTS46 for UTS #46.
Возвращаемые значения
Domain name encoded in ASCII-compatible form. или FALSE в случае возникновения ошибки
Список изменений
Версия | Описание |
---|---|
5.4.0/PECL 2.0.0b1 | Added the parameters variant and idna_info ; UTS #46 support. |
Примеры
Пример #1 idn_to_ascii() example
echo idn_to_ascii ( ‘täst.de’ );
Результат выполнения данного примера:
Смотрите также
Коментарии
The notes on this function are not very clear and a little misleading.
Firstly, =5.4 you will not require the PECL extensions.
Third, use of utf8_encode() is not necessary. In fact, it will potentially prevent idn_to_ascii() from working at all.
On my setup it was necessary to change the charset in the script meta tags to UTF-8:
The above changes mean that idn_to_ascii() can now be used with that syntax (no need for utf8_encode()). Previously, the function worked to convert some IDNs, but failed to convert Japanese and Cyrillic IDNs. Further, no additional locales were enabled or added, and Apache’s charset file was left unmodified.
It is also important to remember only to apply the function where required, eg:
idn_to_ascii(cåsino.com) // is wrong
iden_to_ascii(cåsino) // is right
I have found that Notepad++ easily and reliably handles UTF-8 encoding that works for this function using UTF-8 as the encoding option, not UTF-8 without BOM.
To convert IDN Domains with the IDNA2008 definition use following command.
idn_to_ascii
(PHP 5 >= 5.3.0, PECL intl >= 1.0.2, PECL idn >= 0.1)
idn_to_ascii — Convert domain name to IDNA ASCII form.
Description
This function converts Unicode domain name to IDNA ASCII-compatible format.
Parameters
Domain to convert. In PHP 5 must be UTF-8 encoded.
Either INTL_IDNA_VARIANT_2003 for IDNA 2003 or INTL_IDNA_VARIANT_UTS46 for UTS #46.
Return Values
Domain name encoded in ASCII-compatible form. or FALSE on failure
Changelog
Version | Description |
---|---|
5.4.0/PECL 2.0.0b1 | Added the parameters variant and idna_info ; UTS #46 support. |
Examples
Example #1 idn_to_ascii() example
echo idn_to_ascii ( ‘täst.de’ );
The above example will output:
See Also
Коментарии
The notes on this function are not very clear and a little misleading.
Firstly, =5.4 you will not require the PECL extensions.
Third, use of utf8_encode() is not necessary. In fact, it will potentially prevent idn_to_ascii() from working at all.
On my setup it was necessary to change the charset in the script meta tags to UTF-8:
The above changes mean that idn_to_ascii() can now be used with that syntax (no need for utf8_encode()). Previously, the function worked to convert some IDNs, but failed to convert Japanese and Cyrillic IDNs. Further, no additional locales were enabled or added, and Apache’s charset file was left unmodified.
It is also important to remember only to apply the function where required, eg:
idn_to_ascii(cåsino.com) // is wrong
iden_to_ascii(cåsino) // is right
I have found that Notepad++ easily and reliably handles UTF-8 encoding that works for this function using UTF-8 as the encoding option, not UTF-8 without BOM.
To convert IDN Domains with the IDNA2008 definition use following command.