*******************************************************************************
* *
* IDNA Convert (idna_convert.class.php) *
* *
* http://idnaconv.phlymail.de mailto:phlymail@phlylabs.de *
*******************************************************************************
* (c) 2004-2007 phlyLabs, Berlin *
* This file is encoded in UTF-8 *
*******************************************************************************
Introduction
------------
The class idna_convert allows to convert internationalized domain names
(see RFC 3490, 3491, 3492 and 3454 for detials) as they can be used with various
registries worldwide to be translated between their original (localized) form
and their encoded form as it will be used in the DNS (Domain Name System).
The class provides two public methods, encode() and decode(), which do exactly
what you would expect them to do. You are allowed to use complete domain names,
simple strings and complete email addresses as well. That means, that you might
use any of the following notations:
- www.nörgler.com
- xn--nrgler-wxa
- xn--brse-5qa.xn--knrz-1ra.info
Errors, incorrectly encoded or invalid strings will lead to either a FALSE
response (when in strict mode) or to only partially converted strings.
You can query the occured error by calling the method get_last_error().
Unicode strings are expected to be either UTF-8 strings, UCS-4 strings or UCS-4
arrays. The default format is UTF-8. For setting different encodings, you can
call the method setParams() - please see the inline documentation for details.
ACE strings (the Punycode form) are always 7bit ASCII strings.
ATTENTION: We no longer supply the PHP5 version of the class. It is not
necessary for achieving a successfull conversion, since the supplied PHP code is
compatible with both PHP4 and PHP5. We expect to see no compatibility issues
with the upcoming PHP6, too.
Files
-----
idna_convert.class.php - The actual class
idna_convert.create.npdata.php - Useful for (re)creating the NPData file
npdata.ser - Serialized data for NamePrep
example.php - An example web page for converting
ReadMe.txt - This file
LICENCE - The LGPL licence file
The class is contained in idna_convert.class.php.
MAKE SURE to copy the npdata.ser file into the same folder as the class file
itself!
Examples
--------
1. Say we wish to encode the domain name nörgler.com:
// Include the class
include_once('idna_convert.class.php');
// Instantiate it *
$IDN = new idna_convert();
// The input string, if input is not UTF-8 or UCS-4, it must be converted before
$input = utf8_encode('nörgler.com');
// Encode it to its punycode presentation
$output = $IDN->encode($input);
// Output, what we got now
echo $output; // This will read: xn--nrgler-wxa.com
2. We received an email from a punycoded domain and are willing to learn, how
the domain name reads originally
// Include the class
include_once('idna_convert.class.php');
// Instantiate it (depending on the version you are using) with
$IDN = new idna_convert();
// The input string
$input = 'andre@xn--brse-5qa.xn--knrz-1ra.info';
// Encode it to its punycode presentation
$output = $IDN->decode($input);
// Output, what we got now, if output should be in a format different to UTF-8
// or UCS-4, you will have to convert it before outputting it
echo utf8_decode($output); // This will read: andre@börse.knörz.info
3. The input is read from a UCS-4 coded file and encoded line by line. By
appending the optional second parameter we tell enode() about the input
format to be used
// Include the class
include_once('idna_convert.class.php');
// Instantiate it
$IDN = new dinca_convert();
// Iterate through the input file line by line
foreach (file('ucs4-domains.txt') as $line) {
echo $IDN->encode(trim($line), 'ucs4_string');
echo "\n";
}
NPData
------
Should you need to recreate the npdata.ser file, which holds all necessary translation
tables in a serialized format, you can run the file idna_convert.create.npdata.php, which
creates the file for you and stores it in the same folder, where it is placed.
Should you need to do changes to the tables you can do so, but beware of the consequences.
Contact us
----------
In case of errors, bugs, questions, wishes, please don't hesitate to contact us
under the email address above.
The team of phlyLabs
http://phlylabs.de
mailto:phlymail@phlylabs.de
没有合适的资源?快使用搜索试试~ 我知道了~
[CMS程序]Joomla v1.5.1 繁简英文版_joomla_cn_yeyo.rar
共2000个文件
html:759个
xml:236个
gif:231个
0 下载量 101 浏览量
2024-04-17
03:03:58
上传
评论
收藏 11.78MB RAR 举报
温馨提示
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
收起资源包目录
[CMS程序]Joomla v1.5.1 繁简英文版_joomla_cn_yeyo.rar (2000个子文件)
layout.css 23KB
docbook.css 20KB
general.css 16KB
template.css 13KB
editor_ui.css 8KB
template.css 7KB
template_rtl.css 7KB
icon.css 7KB
theme.css 6KB
calendar-system.css 6KB
editor_popup.css 6KB
theme.css 5KB
general_rtl.css 5KB
calendar-jos.css 4KB
calendar-mos.css 4KB
general.css 3KB
position.css 3KB
menu.css 3KB
fullpage.css 3KB
template_rtl.css 3KB
popup-imagemanager.css 3KB
rounded.css 3KB
type_rtl.css 2KB
popup-imagemanager.css 2KB
type.css 2KB
editor_ui.css 2KB
general.css 2KB
ieonly.css 2KB
login.css 2KB
tabpane_rtl.css 2KB
tabpane.css 2KB
mediamanager.css 2KB
print.css 2KB
medialist-thumbs.css 2KB
error.css 2KB
offline.css 2KB
component.css 1KB
popup-imagelist.css 1KB
system.css 1KB
menu_rtl.css 1KB
media.css 1KB
devkit.css 1KB
popup-imagelist.css 1KB
template.css 1KB
style.css 1KB
editor_content.css 1KB
norounded.css 1KB
contextmenu.css 1KB
modal.css 1KB
props.css 1KB
error.css 1KB
system.css 1KB
login_rtl.css 1KB
editor.css 1KB
medialist-details.css 1KB
inlinepopup.css 1KB
template_rtl.css 1016B
ie7only.css 952B
editor_content.css 878B
toolbar.css 877B
popup.css 859B
dtree_rtl.css 848B
dtree.css 847B
advimage.css 835B
template.css 833B
editor_popup.css 805B
template_rtl.css 788B
orange_bg.css 748B
orange.css 739B
green_bg.css 739B
white_bg.css 736B
black_bg.css 736B
green.css 734B
black.css 733B
white.css 733B
blue_bg.css 730B
blue.css 723B
red.css 721B
red_bg.css 721B
colorpicker.css 716B
content.css 609B
advlink.css 594B
searchreplace.css 536B
poll_bars.css 532B
page.css 530B
editor_content.css 513B
blank.css 395B
help.css 388B
mootree.css 342B
xhtmlxtras.css 332B
row.css 306B
advhr.css 299B
ie6.css 298B
ieonly.css 284B
template.css 275B
devkit_ui.css 222B
cell.css 205B
attributes.css 197B
content.css 190B
noneditable.css 177B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
大黄鸭duck.
- 粉丝: 6691
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功