Commit dedc164e authored by mso's avatar mso

Version 0.8.0 - 2011-03-11

git-svn-id: svn+ssh://85.214.81.201/srv/svn/repos/idna_convert/trunk@3163 35e3bc58-21ef-11dd-9788-dfbd14258a26
parent 7dfa7540
......@@ -4,7 +4,7 @@
* *
* http://idnaconv.phlymail.de mailto:phlymail@phlylabs.de *
*******************************************************************************
* (c) 2004-2010 phlyLabs, Berlin *
* (c) 2004-2011 phlyLabs, Berlin *
* This file is encoded in UTF-8 *
*******************************************************************************
......@@ -45,6 +45,9 @@ containing ß.
In older builds "ß" was mapped to "ss". Should you still need this behaviour,
see example 5 below.
ATTENTION: As of version 0.8.0 the class fully supports IDNA 2008. Thus the
aforementioned parameter is deprecated and replaced by a parameter to switch
between the standards. See the updated example 5 below.
Files
-----
......@@ -121,13 +124,21 @@ $output = $IDN->encode_uri($input);
echo $output; // http://nörgler:secret@xn--nrgler-wxa.com/my_päth_is_not_ÄSCII/
5. Since per default this class does no longer map "ß" to "ss", we wish to enforce
the mapping anyway. Thus we need to pass a parameter to the constructor:
5. To support IDNA 2008, the class needs to be invoked with an additional
parameter. This can also be achieved on an instance.
// Include the class
require_once('idna_convert.class.php');
// Instantiate it
$IDN = new idna_convert(array('encode_german_sz' => false));
$IDN = new idna_convert(array('idn_version' => 2008));
// Sth. containing the German letter ß
$input = 'meine-straße.de');
// Encode it to its punycode presentation
$output = $IDN->encode_uri($input);
// Output, what we got now
echo $output; // xn--meine-strae-46a.de
// Switch back to old IDNA 2003, the original standard
$IDN->set_parameter('idn_version', 2003);
// Sth. containing the German letter ß
$input = 'meine-straße.de');
// Encode it to its punycode presentation
......@@ -136,7 +147,6 @@ $output = $IDN->encode_uri($input);
echo $output; // meine-strasse.de
Transcode wrapper
-----------------
In case you have strings in different encoding than ISO-8859-1 and UTF-8 you might need to
......
......@@ -2,7 +2,16 @@
$encoded = $decoded = $add = '';
header('Content-Type: text/html; charset=utf-8');
require_once('idna_convert.class.php');
$IDN = new idna_convert();
$idn_version = isset($_REQUEST['idn_version']) && $_REQUEST['idn_version'] == 2003 ? 2003 : 2008;
$IDN = new idna_convert(array('idn_version' => $idn_version));
$version_select = '<select size="1" name="idn_version"><option value="2003">IDNA 2003</option><option value="2008"';
if ($idn_version == 2008) {
$version_select .= ' selected="selected"';
}
$version_select .= '>IDNA 2008</option></select>';
if (isset($_REQUEST['encode'])) {
$decoded = isset($_REQUEST['decoded']) ? stripslashes($_REQUEST['decoded']) : '';
$encoded = $IDN->encode($decoded);
......@@ -42,10 +51,15 @@ h5 {margin:0;font-size:11pt;font-weight:bold;}
<div id="round">
<h5>phlyLabs' pure PHP IDNA Converter</h5><br />
<span id="subhead">
See <a href="http://faqs.org/rfcs/rfc3490.html" title="IDNA" target="_blank">RFC3490</a>,
<a href="http://faqs.org/rfcs/rfc3491.html" title="Nameprep, a Stringprep profile" target="_blank">RFC3491</a>,
<a href="http://faqs.org/rfcs/rfc3492.html" title="Punycode" target="_blank">RFC3492</a> and
<a href="http://faqs.org/rfcs/rfc3454.html" title="Stringprep" target="_blank">RFC3454</a><br />
See the RFCs <a href="http://faqs.org/rfcs/rfc3490.html" title="IDNA" target="_blank">3490</a>,
<a href="http://faqs.org/rfcs/rfc3491.html" title="Nameprep, a Stringprep profile" target="_blank">3491</a>,
<a href="http://faqs.org/rfcs/rfc3492.html" title="Punycode" target="_blank">3492</a> and
<a href="http://faqs.org/rfcs/rfc3454.html" title="Stringprep" target="_blank">3454</a> as well as
<a href="http://faqs.org/rfcs/rfc5890.html" target="_blank">5890</a>,
<a href="http://faqs.org/rfcs/rfc5891.html" target="_blank">5891</a>,
<a href="http://faqs.org/rfcs/rfc5892.html" target="_blank">5892</a>,
<a href="http://faqs.org/rfcs/rfc5893.html" target="_blank">5893</a> and
<a href="http://faqs.org/rfcs/rfc5894.html" target="_blank">RFC5894</a>.<br />
</span>
<br />
<div id="bla"><?php if ($lang == 'de') { ?>
......@@ -97,6 +111,7 @@ h5 {margin:0;font-size:11pt;font-weight:bold;}
<td align="right">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<input type="text" name="decoded" value="<?php echo htmlentities($decoded, null, 'UTF-8'); ?>" size="48" maxlength="255" /><br />
<?php echo $version_select; ?>
<input type="submit" name="encode" value="Encode &gt;&gt;" /><?php echo $add; ?>
</form>
</td>
......@@ -110,7 +125,7 @@ h5 {margin:0;font-size:11pt;font-weight:bold;}
</tbody>
</table>
<br />
<span id="copy">Version used: 0.6.9; &copy; 2004-2010 phlyLabs Berlin; part of <a href="http://phlymail.com/">phlyMail</a></span>
<span id="copy">Version used: 0.8.0; &copy; 2004-2011 phlyLabs Berlin; part of <a href="http://phlymail.com/">phlyMail</a></span>
</div>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment