source: project/wiki/eggref/3/idna @ 13621

Last change on this file since 13621 was 13621, checked in by sjamaan, 11 years ago

Move old chicken 3 eggs over to eggref/3

File size: 3.8 KB
Line 
1[[tags:eggs]]
2
3[[toc:]]
4
5== Description
6
7An interface to Internationalizing Domain Names in Applications (IDNA).
8
9== Documentation
10
11The {{idna}} egg allows you to convert Internationalized Domain Names
12from Unicode to a restricted ASCII representation suitable for DNS,
13and vice versa.  It uses [[http://www.gnu.org/software/libidn/|GNU libidn]]
14to do the conversion.
15
16The encoding and decoding mechanism used is
17[[http://wikipedia.org/wiki/Punycode|Punycode]], and the format of the
18resulting ASCII string is called ASCII Compatible Encoding (ACE).  An
19ACE-format string is simply a Punycode string with a unique ACE prefix,
20{{xn--}}, prepended to distinguish it from regular ASCII.
21
22This extension assumes that input and output strings are UTF-8 encoded.
23
24=== Conversion procedures
25
26 '''procedure:''' (idna:nameprep str)
27
28Prepares {{str}} according to the Stringprep profile ''Nameprep''.  In
29simpler terms, it performs processing on {{str}} such as lowercasing
30and other normalization, in order to increase interoperability with
31the DNS, and returns the result.
32
33 '''procedure:''' (idna:to-ascii str)
34
35Convert UTF-8 domain name to ASCII string in ACE format.  All
36''labels'' (sections of a domain name, separated by dots) are
37converted.
38
39The ToASCII algorithm will apply ''NamePrep'' to an individual label
40before conversion if it detects any non-ASCII characters, but does not
41do so if the label is entirely ASCII.  You may wish to pass the entire
42string through {{idna:nameprep}} beforehand in order to lowercase the
43pure-ASCII labels.
44
45An error will be signaled on certain fatal conditions
46(for example, if the result is too long for DNS, or if the
47input is non-ASCII yet already contains the ACE prefix).
48
49 '''procedure:''' (idna:to-unicode str)
50
51Convert ASCII string, possibly in ACE format, to UTF-8.  If decoding
52fails, the original string is returned.  It is therefore safe to pass
53unencoded ASCII strings to this procedure.
54
55== Examples
56
57 (idna:nameprep "WWW.Λ-CALCULUS.GOV")   ; => "www.λ-calculus.gov"
58 (idna:to-ascii "www.λ-calculus.gov")   ; => "www.xn---calculus-k0g.gov"
59 (idna:to-ascii "WWW.Λ-CALCULUS.GOV")   ; => "WWW.xn---calculus-k0g.GOV"
60 (idna:to-unicode "www.xn---calculus-k0g.gov")  ; => "www.λ-calculus.gov"
61
62== About this egg
63
64=== Author
65
66[[http://3e8.org/zb|Zbigniew]]
67
68=== Version history
69
70; 0.1 : Initial release
71
72=== Requirements
73
74GNU libidn
75
76=== License
77
78 Copyright (c) 2007 Jim Ursetto.  All rights reserved.
79 
80 Redistribution and use in source and binary forms, with or without
81 modification, are permitted provided that the following conditions are met:
82 
83   Redistributions of source code must retain the above copyright notice,
84   this list of conditions and the following disclaimer. Redistributions in
85   binary form must reproduce the above copyright notice, this list of
86   conditions and the following disclaimer in the documentation and/or
87   other materials provided with the distribution. Neither the name of the
88   author nor the names of its contributors may be used to endorse or
89   promote products derived from this software without specific prior
90   written permission.
91 
92 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
93 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
94 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
96 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
97 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
98 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
99 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
100 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
101 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
102 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103
Note: See TracBrowser for help on using the repository browser.