Hacked By AnonymousFox

Current Path : /usr/share/doc/libidn-devel/
Upload File :
Current File : //usr/share/doc/libidn-devel/libidn.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This manual is last updated 21 June 2017 for version
1.34 of GNU Libidn.

Copyright (C) 2002-2016 Simon Josefsson.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
copy of the license is included in the section entitled "GNU Free
Documentation License". -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>GNU Libidn 1.34</title>

<meta name="description" content="GNU Libidn 1.34">
<meta name="keywords" content="GNU Libidn 1.34">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="#Top" rel="start" title="Top">
<link href="#Function-and-Variable-Index" rel="index" title="Function and Variable Index">
<link href="#SEC_Contents" rel="contents" title="Table of Contents">
<link href="dir.html#Top" rel="up" title="(dir)">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
body {
	margin: 2%;
	padding: 0 5%;
	background: #ffffff;
}
h1,h2,h3,h4,h5 {
    font-weight: bold;
    padding: 5px 5px 5px 5px;
    background-color: #c2e0ff;
    color: #336699;
}
h1 {
    padding: 2em 2em 2em 5%;
    color: white;
    background: #336699;
    text-align: center;
    letter-spacing: 3px;
}
h2 { text-decoration: underline; }
pre {
  margin: 0 5%;
  padding: 0.5em;
}
pre.example {
  border: solid 1px;
  background: #eeeeff;
  padding-bottom: 1em;
}
pre.verbatim {
  border: solid 1px gray;
  background: white;
  padding-bottom: 1em;
}
div.node {
  margin: 0 -5% 0 -2%;
  padding: 0.5em 0.5em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  font-weight: bold;
}
dd, li {
  padding-top: 0.1em;
  padding-bottom: 0.1em;
}

-->
</style>


</head>

<body lang="en">
<h1 class="settitle" align="center">GNU Libidn 1.34</h1>







<a name="SEC_Contents"></a>
<h2 class="contents-heading">Table of Contents</h2>

<div class="contents">

<ul class="no-bullet">
  <li><a name="toc-Introduction-1" href="#Introduction">1 Introduction</a>
  <ul class="no-bullet">
    <li><a name="toc-Getting-Started-1" href="#Getting-Started">1.1 Getting Started</a></li>
    <li><a name="toc-Features-1" href="#Features">1.2 Features</a></li>
    <li><a name="toc-Library-Overview-1" href="#Library-Overview">1.3 Library Overview</a></li>
    <li><a name="toc-Supported-Platforms-1" href="#Supported-Platforms">1.4 Supported Platforms</a></li>
    <li><a name="toc-Getting-help-1" href="#Getting-help">1.5 Getting help</a></li>
    <li><a name="toc-Commercial-Support-1" href="#Commercial-Support">1.6 Commercial Support</a></li>
    <li><a name="toc-Downloading-and-Installing-1" href="#Downloading-and-Installing">1.7 Downloading and Installing</a>
    <ul class="no-bullet">
      <li><a name="toc-Installing-under-Windows-1" href="#Installing-under-Windows">1.7.1 Installing under Windows</a></li>
    </ul></li>
    <li><a name="toc-Bug-Reports-1" href="#Bug-Reports">1.8 Bug Reports</a></li>
    <li><a name="toc-Contributing-1" href="#Contributing">1.9 Contributing</a></li>
  </ul></li>
  <li><a name="toc-Preparation-1" href="#Preparation">2 Preparation</a>
  <ul class="no-bullet">
    <li><a name="toc-Header-1" href="#Header">2.1 Header</a></li>
    <li><a name="toc-Initialization-1" href="#Initialization">2.2 Initialization</a></li>
    <li><a name="toc-Version-Check-1" href="#Version-Check">2.3 Version Check</a></li>
    <li><a name="toc-Building-the-source-1" href="#Building-the-source">2.4 Building the source</a></li>
    <li><a name="toc-Autoconf-tests-1" href="#Autoconf-tests">2.5 Autoconf tests</a></li>
    <li><a name="toc-Memory-handling-under-Windows-1" href="#Memory-handling-under-Windows">2.6 Memory handling under Windows</a></li>
    <li><a name="toc-Header-file-idn_002dfree_002eh" href="#Header-file-idn_002dfree_002eh">2.7 Header file <code>idn-free.h</code></a></li>
    <li><a name="toc-Memory-de_002dallocation-function" href="#Memory-de_002dallocation-function">2.8 Memory de-allocation function</a></li>
  </ul></li>
  <li><a name="toc-Utility-Functions-1" href="#Utility-Functions">3 Utility Functions</a>
  <ul class="no-bullet">
    <li><a name="toc-Header-file-stringprep_002eh" href="#Header-file-stringprep_002eh">3.1 Header file <code>stringprep.h</code></a></li>
    <li><a name="toc-Unicode-Encoding-Transformation" href="#Unicode-Encoding-Transformation">3.2 Unicode Encoding Transformation</a></li>
    <li><a name="toc-Unicode-Normalization" href="#Unicode-Normalization">3.3 Unicode Normalization</a></li>
    <li><a name="toc-Character-Set-Conversion" href="#Character-Set-Conversion">3.4 Character Set Conversion</a></li>
  </ul></li>
  <li><a name="toc-Stringprep-Functions-1" href="#Stringprep-Functions">4 Stringprep Functions</a>
  <ul class="no-bullet">
    <li><a name="toc-Header-file-stringprep_002eh-1" href="#Header-file-stringprep_002eh-1">4.1 Header file <code>stringprep.h</code></a></li>
    <li><a name="toc-Defining-A-Stringprep-Profile" href="#Defining-A-Stringprep-Profile">4.2 Defining A Stringprep Profile</a></li>
    <li><a name="toc-Control-Flags" href="#Control-Flags">4.3 Control Flags</a></li>
    <li><a name="toc-Core-Functions" href="#Core-Functions">4.4 Core Functions</a></li>
    <li><a name="toc-Error-Handling" href="#Error-Handling">4.5 Error Handling</a></li>
    <li><a name="toc-Stringprep-Profile-Macros" href="#Stringprep-Profile-Macros">4.6 Stringprep Profile Macros</a></li>
  </ul></li>
  <li><a name="toc-Punycode-Functions-1" href="#Punycode-Functions">5 Punycode Functions</a>
  <ul class="no-bullet">
    <li><a name="toc-Header-file-punycode_002eh" href="#Header-file-punycode_002eh">5.1 Header file <code>punycode.h</code></a></li>
    <li><a name="toc-Unicode-Code-Point-Data-Type" href="#Unicode-Code-Point-Data-Type">5.2 Unicode Code Point Data Type</a></li>
    <li><a name="toc-Core-Functions-1" href="#Core-Functions-1">5.3 Core Functions</a></li>
    <li><a name="toc-Error-Handling-1" href="#Error-Handling-1">5.4 Error Handling</a></li>
  </ul></li>
  <li><a name="toc-IDNA-Functions-1" href="#IDNA-Functions">6 IDNA Functions</a>
  <ul class="no-bullet">
    <li><a name="toc-Header-file-idna_002eh" href="#Header-file-idna_002eh">6.1 Header file <code>idna.h</code></a></li>
    <li><a name="toc-Control-Flags-1" href="#Control-Flags-1">6.2 Control Flags</a></li>
    <li><a name="toc-Prefix-String" href="#Prefix-String">6.3 Prefix String</a></li>
    <li><a name="toc-Core-Functions-2" href="#Core-Functions-2">6.4 Core Functions</a></li>
    <li><a name="toc-Simplified-ToASCII-Interface" href="#Simplified-ToASCII-Interface">6.5 Simplified ToASCII Interface</a></li>
    <li><a name="toc-Simplified-ToUnicode-Interface" href="#Simplified-ToUnicode-Interface">6.6 Simplified ToUnicode Interface</a></li>
    <li><a name="toc-Error-Handling-2" href="#Error-Handling-2">6.7 Error Handling</a></li>
  </ul></li>
  <li><a name="toc-TLD-Functions-1" href="#TLD-Functions">7 TLD Functions</a>
  <ul class="no-bullet">
    <li><a name="toc-Header-file-tld_002eh" href="#Header-file-tld_002eh">7.1 Header file <code>tld.h</code></a></li>
    <li><a name="toc-Core-Functions-3" href="#Core-Functions-3">7.2 Core Functions</a></li>
    <li><a name="toc-Utility-Functions-2" href="#Utility-Functions-2">7.3 Utility Functions</a></li>
    <li><a name="toc-High_002dLevel-Wrapper-Functions" href="#High_002dLevel-Wrapper-Functions">7.4 High-Level Wrapper Functions</a></li>
    <li><a name="toc-Error-Handling-3" href="#Error-Handling-3">7.5 Error Handling</a></li>
  </ul></li>
  <li><a name="toc-PR29-Functions-1" href="#PR29-Functions">8 PR29 Functions</a>
  <ul class="no-bullet">
    <li><a name="toc-Header-file-pr29_002eh" href="#Header-file-pr29_002eh">8.1 Header file <code>pr29.h</code></a></li>
    <li><a name="toc-Core-Functions-4" href="#Core-Functions-4">8.2 Core Functions</a></li>
    <li><a name="toc-Utility-Functions-3" href="#Utility-Functions-3">8.3 Utility Functions</a></li>
    <li><a name="toc-Error-Handling-4" href="#Error-Handling-4">8.4 Error Handling</a></li>
  </ul></li>
  <li><a name="toc-Examples-1" href="#Examples">9 Examples</a>
  <ul class="no-bullet">
    <li><a name="toc-Example-1-1" href="#Example-1">9.1 Example 1</a></li>
    <li><a name="toc-Example-2-1" href="#Example-2">9.2 Example 2</a></li>
    <li><a name="toc-Example-3-1" href="#Example-3">9.3 Example 3</a></li>
    <li><a name="toc-Example-4-1" href="#Example-4">9.4 Example 4</a></li>
    <li><a name="toc-Example-5-1" href="#Example-5">9.5 Example 5</a></li>
  </ul></li>
  <li><a name="toc-Invoking-idn-1" href="#Invoking-idn">10 Invoking idn</a>
  <ul class="no-bullet">
    <li><a name="toc-Name" href="#Name">10.1 Name</a></li>
    <li><a name="toc-Description" href="#Description">10.2 Description</a></li>
    <li><a name="toc-Options" href="#Options">10.3 Options</a></li>
    <li><a name="toc-Environment-Variables" href="#Environment-Variables">10.4 Environment Variables</a></li>
    <li><a name="toc-Examples-2" href="#Examples-2">10.5 Examples</a></li>
    <li><a name="toc-Troubleshooting" href="#Troubleshooting">10.6 Troubleshooting</a></li>
  </ul></li>
  <li><a name="toc-Emacs-API-1" href="#Emacs-API">11 Emacs API</a>
  <ul class="no-bullet">
    <li><a name="toc-Punycode-Emacs-API" href="#Punycode-Emacs-API">11.1 Punycode Emacs API</a></li>
    <li><a name="toc-IDNA-Emacs-API" href="#IDNA-Emacs-API">11.2 IDNA Emacs API</a></li>
  </ul></li>
  <li><a name="toc-Java-API-1" href="#Java-API">12 Java API</a>
  <ul class="no-bullet">
    <li><a name="toc-Overview" href="#Overview">12.1 Overview</a></li>
    <li><a name="toc-Miscellaneous-Programs" href="#Miscellaneous-Programs">12.2 Miscellaneous Programs</a>
    <ul class="no-bullet">
      <li><a name="toc-GenerateRFC3454" href="#GenerateRFC3454">12.2.1 GenerateRFC3454</a></li>
      <li><a name="toc-GenerateNFKC" href="#GenerateNFKC">12.2.2 GenerateNFKC</a></li>
      <li><a name="toc-TestIDNA" href="#TestIDNA">12.2.3 TestIDNA</a></li>
      <li><a name="toc-TestNFKC" href="#TestNFKC">12.2.4 TestNFKC</a></li>
    </ul></li>
    <li><a name="toc-Possible-Problems" href="#Possible-Problems">12.3 Possible Problems</a></li>
    <li><a name="toc-A-Note-on-Java-and-Unicode" href="#A-Note-on-Java-and-Unicode">12.4 A Note on Java and Unicode</a></li>
  </ul></li>
  <li><a name="toc-C_0023-API-1" href="#C_0023-API">13 C# API</a></li>
  <li><a name="toc-Acknowledgements-1" href="#Acknowledgements">14 Acknowledgements</a></li>
  <li><a name="toc-History-1" href="#History">15 History</a></li>
  <li><a name="toc-PR29-discussion-1" href="#PR29-discussion">Appendix A PR29 discussion</a></li>
  <li><a name="toc-On-Label-Separators-1" href="#On-Label-Separators">Appendix B On Label Separators</a>
  <ul class="no-bullet">
    <li><a name="toc-Recommended-Workaround" href="#Recommended-Workaround">B.1 Recommended Workaround</a></li>
  </ul></li>
  <li><a name="toc-Copying-Information-1" href="#Copying-Information">Appendix C Copying Information</a>
  <ul class="no-bullet">
    <li><a name="toc-GNU-Free-Documentation-License-1" href="#GNU-Free-Documentation-License">C.1 GNU Free Documentation License</a></li>
  </ul></li>
  <li><a name="toc-Function-and-Variable-Index-1" href="#Function-and-Variable-Index">Function and Variable Index</a></li>
  <li><a name="toc-Concept-Index-1" href="#Concept-Index">Concept Index</a></li>
</ul>
</div>


<a name="Top"></a>
<div class="header">
<p>
Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="GNU-Libidn"></a>
<h1 class="top">GNU Libidn</h1>

<p>This manual is last updated 21 June 2017 for version
1.34 of GNU Libidn.
</p>
<p>Copyright &copy; 2002-2016 Simon Josefsson.
</p>
<blockquote>
<p>Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
copy of the license is included in the section entitled &ldquo;GNU Free
Documentation License&rdquo;.
</p></blockquote>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Introduction" accesskey="1">Introduction</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to use this manual.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Preparation" accesskey="2">Preparation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What you should do before using the library.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Utility-Functions" accesskey="3">Utility Functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Unicode transformation utility functions.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Stringprep-Functions" accesskey="4">Stringprep Functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Stringprep functions.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Punycode-Functions" accesskey="5">Punycode Functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Punycode functions.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#IDNA-Functions" accesskey="6">IDNA Functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">IDNA functions.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#TLD-Functions" accesskey="7">TLD Functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">TLD functions.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#PR29-Functions" accesskey="8">PR29 Functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Detect strings non-idempotent under NFKC.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Examples" accesskey="9">Examples</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Demonstrate how to use the library.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Invoking-idn">Invoking idn</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Command line interface to the library.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Emacs-API">Emacs API</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Emacs Lisp API for Libidn.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Java-API">Java API</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Notes on the Java port of Libidn.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#C_0023-API">C# API</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Notes on the C# port of Libidn.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Acknowledgements">Acknowledgements</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Whom to blame.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#History">History</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Rough outline of development history.
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">

Appendices

</pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#PR29-discussion">PR29 discussion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Implementation aspects of the PR29 flaw.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#On-Label-Separators">On Label Separators</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Discussions of a flaw in the IDNA spec.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Copying-Information">Copying Information</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">License texts.
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">

Indices

</pre></th></tr><tr><td align="left" valign="top">&bull; <a href="#Function-and-Variable-Index">Function and Variable Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Concept-Index">Concept Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">

</pre></th></tr></table>


<hr>
<a name="Introduction"></a>
<div class="header">
<p>
Next: <a href="#Preparation" accesskey="n" rel="next">Preparation</a>, Previous: <a href="#Top" accesskey="p" rel="prev">Top</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Introduction-1"></a>
<h2 class="chapter">1 Introduction</h2>

<p>GNU Libidn is a fully documented implementation of the Stringprep,
Punycode and IDNA specifications.  Libidn&rsquo;s purpose is to encode and
decode internationalized domain name strings.  There are native C, C#
and Java libraries.
</p>
<p>The C library contains a generic Stringprep implementation.  Profiles
for Nameprep, iSCSI, SASL, XMPP and Kerberos V5 are included.
Punycode and ASCII Compatible Encoding (ACE) via IDNA are supported.
A mechanism to define Top-Level Domain (TLD) specific validation
tables, and to compare strings against those tables, is included.
Default tables for some TLDs are also included.
</p>
<p>The Stringprep API consists of two main functions, one for converting
data from the system&rsquo;s native representation into UTF-8, and one
function to perform the Stringprep processing.  Adding a new
Stringprep profile for your application within the API is
straightforward.  The Punycode API consists of one encoding function
and one decoding function.  The IDNA API consists of the ToASCII and
ToUnicode functions, as well as an high-level interface for converting
entire domain names to and from the ACE encoded form.  The TLD API
consists of one set of functions to extract the TLD name from a domain
string, one set of functions to locate the proper TLD table to use
based on the TLD name, and core functions to validate a string against
a TLD table, and some utility wrappers to perform all the steps in one
call.
</p>
<p>The library is used by, e.g., GNU SASL and Shishi to process user
names and passwords.  Libidn can be built into GNU Libc to enable a
new system-wide getaddrinfo flag for IDN processing.
</p>
<p>Libidn is developed for the GNU/Linux system, but runs on over 20 Unix
platforms (including Solaris, IRIX, AIX, and Tru64) and Windows.  The
library is written in C and (parts of) the API is also accessible from
C++, Emacs Lisp, Python and Java.  A native Java and C# port is
included.
</p>
<p>Also included is a command line tool, several self tests, code
examples, and more.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Getting-Started" accesskey="1">Getting Started</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Features" accesskey="2">Features</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Library-Overview" accesskey="3">Library Overview</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Supported-Platforms" accesskey="4">Supported Platforms</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Getting-help" accesskey="5">Getting help</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Commercial-Support" accesskey="6">Commercial Support</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Downloading-and-Installing" accesskey="7">Downloading and Installing</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Bug-Reports" accesskey="8">Bug Reports</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Contributing" accesskey="9">Contributing</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<a name="Getting-Started"></a>
<div class="header">
<p>
Next: <a href="#Features" accesskey="n" rel="next">Features</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Getting-Started-1"></a>
<h3 class="section">1.1 Getting Started</h3>

<p>This manual documents the library programming interface.  All
functions and data types provided by the library are explained.
Included are also examples, and documentation for the command line
tool <samp>idn</samp> that provide a quick interface to the library.  The
Emacs Lisp bindings for the library is also discussed.
</p>
<p>The reader is assumed to possess basic familiarity with
internationalization concepts and network programming in C or C++.
</p>
<p>This manual can be used in several ways.  If read from the beginning
to the end, it gives a good introduction into the library and how it
can be used in an application.  Forward references are included where
necessary.  Later on, the manual can be used as a reference manual to
get just the information needed about any particular interface of the
library.  Experienced programmers might want to start looking at the
examples at the end of the manual (see <a href="#Examples">Examples</a>), and then only
read up those parts of the interface which are unclear.
</p>
<hr>
<a name="Features"></a>
<div class="header">
<p>
Next: <a href="#Library-Overview" accesskey="n" rel="next">Library Overview</a>, Previous: <a href="#Getting-Started" accesskey="p" rel="prev">Getting Started</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Features-1"></a>
<h3 class="section">1.2 Features</h3>

<p>This library might have a couple of advantages over other libraries
doing a similar job.
</p>
<dl compact="compact">
<dt>It&rsquo;s Free Software</dt>
<dd><p>Anybody can use, modify, and redistribute it under the terms of a free
software license.
</p>
</dd>
<dt>It&rsquo;s thread-safe</dt>
<dd><p>No global state is kept in the library.  All functions are re-entrant.
</p>
</dd>
<dt>It&rsquo;s portable</dt>
<dd><p>The code is intended to be written in pure ANSI C89.  It has been
tested on many Unix like operating systems, and Windows.
</p>
</dd>
<dt>It&rsquo;s modularized</dt>
<dd><p>The library is composed of several modules, and the only interaction
between modules is through each modules&rsquo; public API.  If you only need
one piece of functionality, it is possible to take the files you need
and incorporate them into your own project.
</p>
</dd>
<dt>It&rsquo;s not bloated</dt>
<dd><p>The design of the library is based on the smallest API necessary to
implement the basic functionality.  It has been carefully extended
with a small number of high-level wrappers to make it comfortable to
use the library.  However, it does not implement additional
functionality just for the sake of completeness.
</p>
</dd>
<dt>It&rsquo;s documented</dt>
<dd><p>Sadly, not all software comes with documentation these days.  This one
does.
</p>
</dd>
</dl>

<hr>
<a name="Library-Overview"></a>
<div class="header">
<p>
Next: <a href="#Supported-Platforms" accesskey="n" rel="next">Supported Platforms</a>, Previous: <a href="#Features" accesskey="p" rel="prev">Features</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Library-Overview-1"></a>
<h3 class="section">1.3 Library Overview</h3>

<p>The following illustration show the components that make up Libidn,
and how your application relates to the library.  In the illustration,
various components are shown as boxes.  You see the generic StringPrep
component, the various StringPrep profiles including Nameprep, the
Punycode component, the IDNA component, and the TLD component.  The
arrows indicate aggregation, e.g., IDNA uses Punycode and Nameprep,
and in turn Nameprep uses the generic StringPrep interface.  The
interfaces to all components are available for applications, no
component within the library is hidden from the application.
</p>
<img src="libidn-components.png" alt="libidn-components">

<hr>
<a name="Supported-Platforms"></a>
<div class="header">
<p>
Next: <a href="#Getting-help" accesskey="n" rel="next">Getting help</a>, Previous: <a href="#Library-Overview" accesskey="p" rel="prev">Library Overview</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Supported-Platforms-1"></a>
<h3 class="section">1.4 Supported Platforms</h3>

<p>Libidn has at some point in time been tested on the following
platforms.  Build reports for each platforms and Libidn version is
available at <a href="http://autobuild.josefsson.org/libidn/">http://autobuild.josefsson.org/libidn/</a>.
</p>
<ol>
<li> Debian GNU/Linux 3.0 (Woody)
<a name="index-Debian"></a>

<p>GCC 2.95.4 and GNU Make. This is the main development platform.
<code>alphaev67-unknown-linux-gnu</code>, <code>alphaev6-unknown-linux-gnu</code>,
<code>arm-unknown-linux-gnu</code>, <code>armv4l-unknown-linux-gnu</code>,
<code>hppa-unknown-linux-gnu</code>, <code>hppa64-unknown-linux-gnu</code>,
<code>i686-pc-linux-gnu</code>, <code>ia64-unknown-linux-gnu</code>,
<code>m68k-unknown-linux-gnu</code>, <code>mips-unknown-linux-gnu</code>,
<code>mipsel-unknown-linux-gnu</code>, <code>powerpc-unknown-linux-gnu</code>,
<code>s390-ibm-linux-gnu</code>, <code>sparc-unknown-linux-gnu</code>,
<code>sparc64-unknown-linux-gnu</code>.
</p>
</li><li> Debian GNU/Linux 2.1
<a name="index-Debian-1"></a>

<p>GCC 2.95.1 and GNU Make. <code>armv4l-unknown-linux-gnu</code>.
</p>
</li><li> Tru64 UNIX
<a name="index-Tru64"></a>

<p>Tru64 UNIX C compiler and Tru64 Make. <code>alphaev67-dec-osf5.1</code>,
<code>alphaev68-dec-osf5.1</code>.
</p>
</li><li> SuSE Linux 7.1
<a name="index-SuSE"></a>

<p>GCC 2.96 and GNU Make. <code>alphaev6-unknown-linux-gnu</code>,
<code>alphaev67-unknown-linux-gnu</code>.
</p>
</li><li> SuSE Linux 7.2a
<a name="index-SuSE-Linux"></a>

<p>GCC 3.0 and GNU Make. <code>ia64-unknown-linux-gnu</code>.
</p>
</li><li> SuSE Linux
<a name="index-SuSE-Linux-1"></a>

<p>GCC 3.2.2 and GNU Make.  <code>x86_64-unknown-linux-gnu</code> (AMD64
Opteron &ldquo;Melody&rdquo;).
</p>
</li><li> SuSE Enterprise Server 9 on IBM OpenPower 720 
<a name="index-SuSE-Linux-2"></a>
<a name="index-OpenPower-720"></a>

<p>GCC 3.3.3 and GNU Make.  <code>powerpc64-unknown-linux-gnu</code>.
</p>
</li><li> RedHat Linux 7.2
<a name="index-RedHat"></a>

<p>GCC 2.96 and GNU Make. <code>alphaev6-unknown-linux-gnu</code>,
<code>alphaev67-unknown-linux-gnu</code>, <code>ia64-unknown-linux-gnu</code>.
</p>
</li><li> RedHat Linux 8.0
<a name="index-RedHat-1"></a>

<p>GCC 3.2 and GNU Make. <code>i686-pc-linux-gnu</code>.
</p>
</li><li> RedHat Advanced Server 2.1
<a name="index-RedHat-Advanced-Server"></a>

<p>GCC 2.96 and GNU Make. <code>i686-pc-linux-gnu</code>.
</p>
</li><li> Slackware Linux 8.0.01
<a name="index-RedHat-2"></a>

<p>GCC 2.95.3 and GNU Make. <code>i686-pc-linux-gnu</code>.
</p>
</li><li> Mandrake Linux 9.0
<a name="index-Mandrake"></a>

<p>GCC 3.2 and GNU Make. <code>i686-pc-linux-gnu</code>.
</p>
</li><li> IRIX 6.5
<a name="index-IRIX"></a>

<p>MIPS C compiler, IRIX Make. <code>mips-sgi-irix6.5</code>.
</p>
</li><li> AIX 4.3.2
<a name="index-AIX"></a>

<p>IBM C for AIX compiler, AIX Make.  <code>rs6000-ibm-aix4.3.2.0</code>.
</p>
</li><li> Microsoft Windows 2000 (Cygwin)
<a name="index-Windows"></a>

<p>GCC 3.2, GNU make. <code>i686-pc-cygwin</code>.
</p>
</li><li> HP-UX 11
<a name="index-HP_002dUX"></a>

<p>HP-UX C compiler and HP Make. <code>ia64-hp-hpux11.22</code>,
<code>hppa2.0w-hp-hpux11.11</code>.
</p>
</li><li> SUN Solaris 2.7
<a name="index-Solaris"></a>

<p>GCC 3.0.4 and GNU Make. <code>sparc-sun-solaris2.7</code>.
</p>
</li><li> SUN Solaris 2.8
<a name="index-Solaris-1"></a>

<p>Sun WorkShop Compiler C 6.0 and SUN Make. <code>sparc-sun-solaris2.8</code>.
</p>
</li><li> SUN Solaris 2.9
<a name="index-Solaris-2"></a>

<p>Sun Forte Developer 7 C compiler and GNU
Make. <code>sparc-sun-solaris2.9</code>.
</p>
</li><li> NetBSD 1.6
<a name="index-NetBSD"></a>

<p>GCC 2.95.3 and GNU Make. <code>alpha-unknown-netbsd1.6</code>,
<code>i386-unknown-netbsdelf1.6</code>.
</p>
</li><li> OpenBSD 3.1 and 3.2
<a name="index-OpenBSD"></a>

<p>GCC 2.95.3 and GNU Make. <code>alpha-unknown-openbsd3.1</code>,
<code>i386-unknown-openbsd3.1</code>.
</p>
</li><li> FreeBSD 4.7 and 4.8
<a name="index-FreeBSD"></a>

<p>GCC 2.95.4 and GNU Make. <code>alpha-unknown-freebsd4.7</code>,
<code>alpha-unknown-freebsd4.8</code>, <code>i386-unknown-freebsd4.7</code>,
<code>i386-unknown-freebsd4.8</code>.
</p>
</li><li> MacOS X 10.2 Server Edition
<a name="index-MacOS-X"></a>

<p>GCC 3.1 and GNU Make. <code>powerpc-apple-darwin6.5</code>.
</p>
</li><li> MacOS X 10.4 &ldquo;Tiger&rdquo; with Xcode 2.0
<a name="index-MacOS-X-1"></a>

<p>GCC 4.0 and GNU Make. <code>powerpc-apple-darwin8.0</code>.
</p>
</li><li> Cross compiled to uClinux/uClibc on Motorola Coldfire
<a name="index-Motorola-Coldfire"></a>
<a name="index-uClinux"></a>
<a name="index-uClibc"></a>

<p>GCC 3.4 and GNU Make <code>m68k-uclinux-elf</code>.
</p>
</li><li> Cross compiled to ARM using Glibc
<a name="index-ARM"></a>

<p>GCC 2.95 and GNU Make <code>arm-linux</code>.
</p>
</li><li> Cross compiled to Mingw32.
<a name="index-Windows-1"></a>
<a name="index-Microsoft"></a>
<a name="index-mingw32"></a>

<p>GCC 3.4.4 and GNU Make <code>i586-mingw32msvc</code>.
</p>
</li><li> OS/2
<a name="index-OS_002f2"></a>
<a name="index-IBM"></a>

<p>GCC.
</p>
</li></ol>

<p>If you use Libidn on, or port Libidn to, a new platform please report
it to the author.
</p>
<hr>
<a name="Getting-help"></a>
<div class="header">
<p>
Next: <a href="#Commercial-Support" accesskey="n" rel="next">Commercial Support</a>, Previous: <a href="#Supported-Platforms" accesskey="p" rel="prev">Supported Platforms</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Getting-help-1"></a>
<h3 class="section">1.5 Getting help</h3>

<p>A mailing list where users of Libidn may help each other exists, and
you can reach it by sending e-mail to <a href="mailto:help-libidn@gnu.org">help-libidn@gnu.org</a>.
Archives of the mailing list discussions, and an interface to manage
subscriptions, is available through the World Wide Web at
<a href="http://lists.gnu.org/mailman/listinfo/help-libidn">http://lists.gnu.org/mailman/listinfo/help-libidn</a>.
</p>
<hr>
<a name="Commercial-Support"></a>
<div class="header">
<p>
Next: <a href="#Downloading-and-Installing" accesskey="n" rel="next">Downloading and Installing</a>, Previous: <a href="#Getting-help" accesskey="p" rel="prev">Getting help</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Commercial-Support-1"></a>
<h3 class="section">1.6 Commercial Support</h3>

<p>Commercial support is available for users of GNU Libidn.  The kind of
support that can be purchased may include:
</p>
<ul>
<li> Implement new features.
Such as country code specific profiling to support a restricted subset
of Unicode.

</li><li> Port Libidn to new platforms.
This could include porting Libidn to an embedded platforms that may
need memory or size optimization.

</li><li> Integrating IDN support in your existing project.

</li><li> System design of components related to IDN.

</li></ul>

<p>If you are interested, please write to:
</p>
<pre class="verbatim">Simon Josefsson Datakonsult AB
Hagagatan 24
113 47 Stockholm
Sweden

E-mail: simon@josefsson.org
</pre>
<p>If your company provides support related to GNU Libidn and would like
to be mentioned here, contact the author (see <a href="#Bug-Reports">Bug Reports</a>).
</p>
<hr>
<a name="Downloading-and-Installing"></a>
<div class="header">
<p>
Next: <a href="#Bug-Reports" accesskey="n" rel="next">Bug Reports</a>, Previous: <a href="#Commercial-Support" accesskey="p" rel="prev">Commercial Support</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Downloading-and-Installing-1"></a>
<h3 class="section">1.7 Downloading and Installing</h3>
<a name="index-Installation"></a>
<a name="index-Download"></a>

<p>The package can be downloaded from several places, including:
</p>
<p><a href="ftp://alpha.gnu.org/pub/gnu/libidn/">ftp://alpha.gnu.org/pub/gnu/libidn/</a>
</p>
<p>The latest version is stored in a file, e.g.,
&lsquo;<samp>libidn-1.34.tar.gz</samp>&rsquo; where the &lsquo;<samp>1.34</samp>&rsquo;
value is the highest version number in the directory.
</p>
<p>The package is then extracted, configured and built like many other
packages that use Autoconf.  For detailed information on configuring
and building it, refer to the <samp>INSTALL</samp> file that is part of the
distribution archive.
</p>
<p>Here is an example terminal session that download, configure, build
and install the package.  You will need a few basic tools, such as
&lsquo;<samp>sh</samp>&rsquo;, &lsquo;<samp>make</samp>&rsquo; and &lsquo;<samp>cc</samp>&rsquo;.
</p>
<div class="example">
<pre class="example">$ wget -q ftp://alpha.gnu.org/pub/gnu/libidn/libidn-1.34.tar.gz
$ tar xfz libidn-1.34.tar.gz
$ cd libidn-1.34/
$ ./configure
...
$ make
...
$ make install
...
</pre></div>

<p>After that Libidn should be properly installed and ready for use.
</p>
<p>A few <code>configure</code> options may be relevant, summarized in the
table.
</p>
<dl compact="compact">
<dt><code>--enable-java</code></dt>
<dd><p>Build the Java port into a *.JAR file.  See <a href="#Java-API">Java API</a>, for more
information.
</p>
</dd>
<dt><code>--disable-tld</code></dt>
<dd><p>Disable the TLD module.  This would typically only be useful if you
are building on a memory restricted platforms.  See <a href="#TLD-Functions">TLD Functions</a>,
for more information.
</p>
</dd>
<dt><code>--enable-csharp[=IMPL]</code></dt>
<dd><p>Build the <code>C#</code> port into a <code>*.DLL</code> file.  See <a href="#C_0023-API">C# API</a>, for
more information.  Here, <code>IMPL</code> is <code>pnet</code> or <code>mono</code>,
indicating whether the PNET <code>cscc</code> compiler or the Mono
<code>mcs</code> compiler should be used, respectively.
</p>
</dd>
<dt><code>--disable-valgrind-tests</code></dt>
<dd><p>Disable running the self-checks under Valgrind
(<a href="http://valgrind.org/">http://valgrind.org/</a>).  Normally Valgrind does not cause
problems and can detect some severe memory errors.  If you are getting
errors from Valgrind that are caused by the compiler or libc (possibly
as a result of special optimization flags), you may use this option to
disable the use of Valgrind.
</p>
</dd>
</dl>

<p>For the complete list, refer to the output from <code>configure
--help</code>.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Installing-under-Windows" accesskey="1">Installing under Windows</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Windows specific build instructions.
</td></tr>
</table>

<hr>
<a name="Installing-under-Windows"></a>
<div class="header">
<p>
Up: <a href="#Downloading-and-Installing" accesskey="u" rel="up">Downloading and Installing</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Installing-under-Windows-1"></a>
<h4 class="subsection">1.7.1 Installing under Windows</h4>

<p>There are two ways to build Libidn on Windows: via MinGW or via Visual
Studio.
</p>
<p>With MinGW, you can build a Libidn DLL and use it from other
applications.  After installing MinGW (<a href="http://mingw.org/">http://mingw.org/</a>) follow
the generic installation instructions (see <a href="#Downloading-and-Installing">Downloading and Installing</a>).  The DLL is installed by default.
</p>
<p>For information on how to use the DLL in other applications, see:
<a href="http://www.mingw.org/mingwfaq.shtml#faq-msvcdll">http://www.mingw.org/mingwfaq.shtml#faq-msvcdll</a>.
</p>
<p>You can build Libidn as a native Visual Studio C++ project.  This
allows you to build the code for other platforms that VS supports,
such as Windows Mobile.  You need Visual Studio 2005 or later.
</p>
<p>First download and unpack the archive as described in the generic
installation instructions (see <a href="#Downloading-and-Installing">Downloading and Installing</a>).  Don&rsquo;t
run <code>./configure</code>.  Instead, start Visual Studio and open the
project file <samp>windows/libidn.sln</samp> inside the Libidn directory.  You
should be able to build the project using Build Project.
</p>
<p>Output libraries will be written into the <code>windows/lib</code> (or
<code>windows/lib/debug</code> for Debug versions) folder.
</p>
<p>When working with Windows you may want to look into the special memory
handling functions that may be needed (see <a href="#Memory-handling-under-Windows">Memory handling under Windows</a>).
</p>
<hr>
<a name="Bug-Reports"></a>
<div class="header">
<p>
Next: <a href="#Contributing" accesskey="n" rel="next">Contributing</a>, Previous: <a href="#Downloading-and-Installing" accesskey="p" rel="prev">Downloading and Installing</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Bug-Reports-1"></a>
<h3 class="section">1.8 Bug Reports</h3>
<a name="index-Reporting-Bugs"></a>

<p>If you think you have found a bug in Libidn, please investigate it and
report it.
</p>
<ul>
<li> Please make sure that the bug is really in Libidn, and
preferably also check that it hasn&rsquo;t already been fixed in the latest
version.

</li><li> You have to send us a test case that makes it possible for us to
reproduce the bug.

</li><li> You also have to explain what is wrong; if you get a crash, or
if the results printed are not good and in that case, in what way.
Make sure that the bug report includes all information you would need
to fix this kind of bug for someone else.

</li></ul>

<p>Please make an effort to produce a self-contained report, with
something definite that can be tested or debugged.  Vague queries or
piecemeal messages are difficult to act on and don&rsquo;t help the
development effort.
</p>
<p>If your bug report is good, we will do our best to help you to get a
corrected version of the software; if the bug report is poor, we won&rsquo;t
do anything about it (apart from asking you to send better bug
reports).
</p>
<p>If you think something in this manual is unclear, or downright
incorrect, or if the language needs to be improved, please also send a
note.
</p>
<p>Send your bug report to:
</p>
<div align="center">&lsquo;<samp>bug-libidn@gnu.org</samp>&rsquo;
</div>

<hr>
<a name="Contributing"></a>
<div class="header">
<p>
Previous: <a href="#Bug-Reports" accesskey="p" rel="prev">Bug Reports</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Contributing-1"></a>
<h3 class="section">1.9 Contributing</h3>
<a name="index-Contributing"></a>
<a name="index-Hacking"></a>

<p>If you want to submit a patch for inclusion &ndash; from solve a typo you
discovered, up to adding support for a new feature &ndash; you should
submit it as a bug report (see <a href="#Bug-Reports">Bug Reports</a>).  There are some
things that you can do to increase the chances for it to be included
in the official package.
</p>
<p>Unless your patch is very small (say, under 10 lines) we require that
you assign the copyright of your work to the Free Software Foundation.
This is to protect the freedom of the project.  If you have not
already signed papers, we will send you the necessary information when
you submit your contribution.
</p>
<p>For contributions that doesn&rsquo;t consist of actual programming code, the
only guidelines are common sense.  Use it.
</p>
<p>For code contributions, a number of style guides will help you:
</p>
<ul>
<li> Coding Style.
Follow the GNU Standards document (see <a href="http://www.gnu.org/prep/standards/standards.html#Top">(standards)GNU Coding Standards</a>).

<p>If you normally code using another coding standard, there is no
problem, but you should use &lsquo;<samp>indent</samp>&rsquo; to reformat the code
(see <a href="indent.html#Top">(indent)GNU Indent</a>) before submitting your work.
</p>
</li><li> Use the unified diff format &lsquo;<samp>diff -u</samp>&rsquo;.

</li><li> Return errors.
No reason whatsoever should abort the execution of the library.  Even
memory allocation errors, e.g. when malloc return NULL, should work
although result in an error code.

</li><li> Design with thread safety in mind.
Don&rsquo;t use global variables and the like.

</li><li> Avoid using the C math library.
It causes problems for embedded implementations, and in most
situations it is very easy to avoid using it.

</li><li> Document your functions.
Use comments before each function headers, that, if properly
formatted, are extracted into GTK-DOC web pages.  Don&rsquo;t forget to
update the Texinfo manual as well.

</li><li> Supply a ChangeLog and NEWS entries, where appropriate.

</li></ul>

<hr>
<a name="Preparation"></a>
<div class="header">
<p>
Next: <a href="#Utility-Functions" accesskey="n" rel="next">Utility Functions</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Preparation-1"></a>
<h2 class="chapter">2 Preparation</h2>

<p>To use &lsquo;Libidn&rsquo;, you have to perform some changes to your sources and
the build system.  The necessary changes are small and explained in
the following sections.  At the end of this chapter, it is described
how the library is initialized, and how the requirements of the
library are verified.
</p>
<p>A faster way to find out how to adapt your application for use with
&lsquo;Libidn&rsquo; may be to look at the examples at the end of this manual
(see <a href="#Examples">Examples</a>).
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Header" accesskey="1">Header</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Initialization" accesskey="2">Initialization</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Version-Check" accesskey="3">Version Check</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Building-the-source" accesskey="4">Building the source</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Autoconf-tests" accesskey="5">Autoconf tests</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Memory-handling-under-Windows" accesskey="6">Memory handling under Windows</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<a name="Header"></a>
<div class="header">
<p>
Next: <a href="#Initialization" accesskey="n" rel="next">Initialization</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Header-1"></a>
<h3 class="section">2.1 Header</h3>

<p>The library contains a few independent parts, and each part export the
interfaces (data types and functions) in a header file.  You must
include the appropriate header files in all programs using the
library, either directly or through some other header file, like this:
</p>
<div class="example">
<pre class="example">#include &lt;stringprep.h&gt;
</pre></div>

<p>The header files and the functions they define are categorized as
follows:
</p>
<dl compact="compact">
<dt>stringprep.h</dt>
<dd>
<p>The low-level stringprep API entry point.  For IDN applications, this
is usually invoked via IDNA. Some applications, specifically non-IDN
ones, may want to prepare strings directly though, and should include
this header file.
</p>
<p>The name space of the stringprep part of Libidn is <code>stringprep*</code>
for function names, <code>Stringprep*</code> for data types and
<code>STRINGPREP_*</code> for other symbols.  In addition,
<code>_stringprep*</code> is reserved for internal use and should never be
used by applications.
</p>
</dd>
<dt>punycode.h</dt>
<dd>
<p>The entry point to Punycode encoding and decoding functions.  Normally
punycode is used via the idna.h interface, but some application may
want to perform raw punycode operations.
</p>
<p>The name space of the punycode part of Libidn is <code>punycode_*</code> for
function names, <code>Punycode*</code> for data types and <code>PUNYCODE_*</code>
for other symbols.  In addition, <code>_punycode*</code> is reserved for
internal use and should never be used by applications.
</p></dd>
<dt>idna.h</dt>
<dd>
<p>The entry point to the IDNA functions.  This is the normal entry point
for applications that need IDN functionality.
</p>
<p>The name space of the IDNA part of Libidn is <code>idna_*</code> for
function names, <code>Idna*</code> for data types and <code>IDNA_*</code> for
other symbols.  In addition, <code>_idna*</code> is reserved for internal
use and should never be used by applications.
</p>
</dd>
<dt>tld.h</dt>
<dd>
<p>The entry point to the TLD functions.  Normal applications are not
expected to need this functionality, but it is present for
applications that are used by TLDs to validate customer input.
</p>
<p>The name space of the TLD part of Libidn is <code>tld_*</code> for function
names, <code>Tld_*</code> for data types and <code>TLD_*</code> for other symbols.
In addition, <code>_tld*</code> is reserved for internal use and should
never be used by applications.
</p>
</dd>
<dt>pr29.h</dt>
<dd>
<p>The entry point to the PR29 functions.  These functions are used to
detect &ldquo;problem sequences&rdquo; (see <a href="#PR29-Functions">PR29 Functions</a>), mostly for use
in security critical applications.
</p>
<p>The name space of the PR29 part of Libidn is <code>pr29_*</code> for
function names, <code>Pr29_*</code> for data types and <code>PR29_*</code> for
other symbols.  In addition, <code>_pr29*</code> is reserved for internal
use and should never be used by applications.
</p>
</dd>
<dt>idn-free.h</dt>
<dd>
<p>The entry point to the Windows memory de-allocation function
(see <a href="#Memory-handling-under-Windows">Memory handling under Windows</a>).  It contains only one
function <code>idn_free</code>.
</p>
</dd>
</dl>

<p>All header files defined and use the symbol <code>IDNAPI</code> to decorate
the API functions.
</p>
<hr>
<a name="Initialization"></a>
<div class="header">
<p>
Next: <a href="#Version-Check" accesskey="n" rel="next">Version Check</a>, Previous: <a href="#Header" accesskey="p" rel="prev">Header</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Initialization-1"></a>
<h3 class="section">2.2 Initialization</h3>

<p>Libidn is stateless and does not need any initialization.
</p>
<hr>
<a name="Version-Check"></a>
<div class="header">
<p>
Next: <a href="#Building-the-source" accesskey="n" rel="next">Building the source</a>, Previous: <a href="#Initialization" accesskey="p" rel="prev">Initialization</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Version-Check-1"></a>
<h3 class="section">2.3 Version Check</h3>

<p>It is often desirable to check that the version of &lsquo;Libidn&rsquo; used is
indeed one which fits all requirements.  Even with binary
compatibility new features may have been introduced but due to problem
with the dynamic linker an old version is actually used.  So you may
want to check that the version is okay right after program startup.
</p>
<a name="stringprep_005fcheck_005fversion-1"></a>
<h4 class="subheading">stringprep_check_version</h4>
<a name="stringprep_005fcheck_005fversion"></a><dl>
<dt><a name="index-stringprep_005fcheck_005fversion"></a>Function: <em>const char *</em> <strong>stringprep_check_version</strong> <em>(const char * <var>req_version</var>)</em></dt>
<dd><p><var>req_version</var>: Required version number, or NULL.
</p>
<p>Check that the version of the library is at minimum the requested one
and return the version string; return NULL if the condition is not
satisfied.  If a NULL is passed to this function, no check is done,
but the version string is simply returned.
</p>
<p>See <code>STRINGPREP_VERSION</code>  for a suitable  <code>req_version</code> string.
</p>
<p>Return value: Version string of run-time library, or NULL if the
run-time library does not meet the required version number.
</p></dd></dl>


<p>The normal way to use the function is to put something similar to the
following first in your <code>main</code>:
</p>
<div class="example">
<pre class="example">  if (!stringprep_check_version (STRINGPREP_VERSION))
    {
      printf (&quot;stringprep_check_version() failed:\n&quot;
              &quot;Header file incompatible with shared library.\n&quot;);
      exit(EXIT_FAILURE);
    }
</pre></div>

<hr>
<a name="Building-the-source"></a>
<div class="header">
<p>
Next: <a href="#Autoconf-tests" accesskey="n" rel="next">Autoconf tests</a>, Previous: <a href="#Version-Check" accesskey="p" rel="prev">Version Check</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Building-the-source-1"></a>
<h3 class="section">2.4 Building the source</h3>
<a name="index-Compiling-your-application"></a>

<p>If you want to compile a source file including e.g. the &lsquo;idna.h&rsquo; header
file, you must make sure that the compiler can find it in the
directory hierarchy.  This is accomplished by adding the path to the
directory in which the header file is located to the compilers include
file search path (via the <samp>-I</samp> option).
</p>
<p>However, the path to the include file is determined at the time the
source is configured.  To solve this problem, &lsquo;Libidn&rsquo; uses the
external package <code>pkg-config</code> that knows the path to the
include file and other configuration options.  The options that need
to be added to the compiler invocation at compile time are output by
the <samp>--cflags</samp> option to <code>pkg-config libidn</code>.  The
following example shows how it can be used at the command line:
</p>
<div class="example">
<pre class="example">gcc -c foo.c `pkg-config libidn --cflags`
</pre></div>

<p>Adding the output of &lsquo;<samp>pkg-config libidn --cflags</samp>&rsquo; to the
compilers command line will ensure that the compiler can find e.g. the
idna.h header file.
</p>
<p>A similar problem occurs when linking the program with the library.
Again, the compiler has to find the library files.  For this to work,
the path to the library files has to be added to the library search
path (via the <samp>-L</samp> option).  For this, the option
<samp>--libs</samp> to <code>pkg-config libidn</code> can be used.  For
convenience, this option also outputs all other options that are
required to link the program with the &lsquo;libidn&rsquo; library.  The example
shows how to link <samp>foo.o</samp> with the &lsquo;libidn&rsquo; library to a program
<code>foo</code>.
</p>
<div class="example">
<pre class="example">gcc -o foo foo.o `pkg-config libidn --libs`
</pre></div>

<p>Of course you can also combine both examples to a single command by
specifying both options to <code>pkg-config</code>:
</p>
<div class="example">
<pre class="example">gcc -o foo foo.c `pkg-config libidn --cflags --libs`
</pre></div>

<hr>
<a name="Autoconf-tests"></a>
<div class="header">
<p>
Next: <a href="#Memory-handling-under-Windows" accesskey="n" rel="next">Memory handling under Windows</a>, Previous: <a href="#Building-the-source" accesskey="p" rel="prev">Building the source</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Autoconf-tests-1"></a>
<h3 class="section">2.5 Autoconf tests</h3>
<a name="index-Autoconf-tests"></a>
<a name="index-Configure-tests"></a>

<p>If your project uses Autoconf (see <a href="http://www.gnu.org/software/autoconf/manual/autoconf.html#Top">(autoconf)GNU Autoconf</a>)
to check for installed libraries, you might find the following snippet
illustrative.  It add a new <samp>configure</samp> parameter
<code>--with-libidn</code>, and check for <samp>idna.h</samp> and &lsquo;<samp>-lidn</samp>&rsquo;
(possibly below the directory specified as the optional argument to
<code>--with-libidn</code>), and define the CPP symbol <code>LIBIDN</code> if the
library is found.  The default behaviour is to search for the library
and enable the functionality (that is, define the symbol) when the
library is found, but if you wish to make the default behaviour of
your package be that Libidn is not used (even if it is installed on
the system), change &lsquo;<samp>libidn=yes</samp>&rsquo; to &lsquo;<samp>libidn=no</samp>&rsquo; on the third
line.
</p>
<div class="example">
<pre class="example">AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]],
                                [Support IDN (needs GNU Libidn)]),
  libidn=$withval, libidn=yes)
if test &quot;$libidn&quot; != &quot;no&quot;; then
  if test &quot;$libidn&quot; != &quot;yes&quot;; then
    LDFLAGS=&quot;${LDFLAGS} -L$libidn/lib&quot;
    CPPFLAGS=&quot;${CPPFLAGS} -I$libidn/include&quot;
  fi
  AC_CHECK_HEADER(idna.h,
    AC_CHECK_LIB(idn, stringprep_check_version,
      [libidn=yes LIBS=&quot;${LIBS} -lidn&quot;], libidn=no),
    libidn=no)
fi
if test &quot;$libidn&quot; != &quot;no&quot; ; then
  AC_DEFINE(LIBIDN, 1, [Define to 1 if you want IDN support.])
else
  AC_MSG_WARN([Libidn not found])
fi
AC_MSG_CHECKING([if Libidn should be used])
AC_MSG_RESULT($libidn)
</pre></div>

<p>If you require that your users have installed <code>pkg-config</code> (which
I cannot recommend generally), the above can be done more easily as
follows.
</p>
<div class="example">
<pre class="example">AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]],
                                [Support IDN (needs GNU Libidn)]),
  libidn=$withval, libidn=yes)
if test &quot;$libidn&quot; != &quot;no&quot; ; then
  PKG_CHECK_MODULES(LIBIDN, libidn &gt;= 0.0.0, [libidn=yes], [libidn=no])
  if test &quot;$libidn&quot; != &quot;yes&quot; ; then
    libidn=no
    AC_MSG_WARN([Libidn not found])
  else
    libidn=yes
    AC_DEFINE(LIBIDN, 1, [Define to 1 if you want Libidn.])
  fi
fi
AC_MSG_CHECKING([if Libidn should be used])
AC_MSG_RESULT($libidn)
</pre></div>

<hr>
<a name="Memory-handling-under-Windows"></a>
<div class="header">
<p>
Previous: <a href="#Autoconf-tests" accesskey="p" rel="prev">Autoconf tests</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Memory-handling-under-Windows-1"></a>
<h3 class="section">2.6 Memory handling under Windows</h3>
<a name="index-free"></a>
<a name="index-Memory-handling"></a>
<a name="index-de_002dallocation"></a>
<a name="index-heap-memory"></a>

<p>Several functions in the library allocates memory.  The memory is
expected to be de-allocated using the <code>free</code> function.  Under
Windows, it is sometimes necessary to de-allocate memory in the same
module that allocated a memory region.  The reason is that different
modules use separate heap memory regions.  To solve this problem we
provide a function to de-allocate memory inside the library.
</p>
<p>Note that we do not recommend using this interface generally if you do
not care about Windows portability.
</p>
<a name="Header-file-idn_002dfree_002eh"></a>
<h3 class="section">2.7 Header file <code>idn-free.h</code></h3>

<p>To use the function explained in this chapter, you need to include the
file <samp>idn-free.h</samp> using:
</p>
<div class="example">
<pre class="example">#include &lt;idn-free.h&gt;
</pre></div>

<a name="Memory-de_002dallocation-function"></a>
<h3 class="section">2.8 Memory de-allocation function</h3>

<a name="idn_005ffree-1"></a>
<h4 class="subheading">idn_free</h4>
<a name="idn_005ffree"></a><dl>
<dt><a name="index-idn_005ffree"></a>Function: <em>void</em> <strong>idn_free</strong> <em>(void * <var>ptr</var>)</em></dt>
<dd><p><var>ptr</var>: memory region to deallocate, or <code>NULL</code> .
</p>
<p>Deallocates memory region by calling <code>free()</code> .  If  <code>ptr</code> is <code>NULL</code>  no
operation is performed.
</p>
<p>Normally applications de-allocate strings allocated by libidn by
calling <code>free()</code>  directly.  Under Windows, different parts of the
same application may use different heap memory, and then it is
important to deallocate memory allocated within the same module
that allocated it.  This function makes that possible.
</p></dd></dl>


<hr>
<a name="Utility-Functions"></a>
<div class="header">
<p>
Next: <a href="#Stringprep-Functions" accesskey="n" rel="next">Stringprep Functions</a>, Previous: <a href="#Preparation" accesskey="p" rel="prev">Preparation</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Utility-Functions-1"></a>
<h2 class="chapter">3 Utility Functions</h2>
<a name="index-Utility-Functions"></a>

<p>The rest of this library makes extensive use of Unicode characters.
In order to interface this library with the outside world, your
application may need to make various Unicode transformations.
</p>
<a name="Header-file-stringprep_002eh"></a>
<h3 class="section">3.1 Header file <code>stringprep.h</code></h3>

<p>To use the functions explained in this chapter, you need to include
the file <samp>stringprep.h</samp> using:
</p>
<div class="example">
<pre class="example">#include &lt;stringprep.h&gt;
</pre></div>

<a name="Unicode-Encoding-Transformation"></a>
<h3 class="section">3.2 Unicode Encoding Transformation</h3>

<a name="stringprep_005funichar_005fto_005futf8-1"></a>
<h4 class="subheading">stringprep_unichar_to_utf8</h4>
<a name="stringprep_005funichar_005fto_005futf8"></a><dl>
<dt><a name="index-stringprep_005funichar_005fto_005futf8"></a>Function: <em>int</em> <strong>stringprep_unichar_to_utf8</strong> <em>(uint32_t <var>c</var>, char * <var>outbuf</var>)</em></dt>
<dd><p><var>c</var>: a ISO10646 character code
</p>
<p><var>outbuf</var>: output buffer, must have at least 6 bytes of space.
If <code>NULL</code> , the length will be computed and returned
and nothing will be written to  <code>outbuf</code> .
</p>
<p>Converts a single character to UTF-8.
</p>
<p>Return value: number of bytes written.
</p></dd></dl>

<a name="stringprep_005futf8_005fto_005funichar-1"></a>
<h4 class="subheading">stringprep_utf8_to_unichar</h4>
<a name="stringprep_005futf8_005fto_005funichar"></a><dl>
<dt><a name="index-stringprep_005futf8_005fto_005funichar"></a>Function: <em>uint32_t</em> <strong>stringprep_utf8_to_unichar</strong> <em>(const char * <var>p</var>)</em></dt>
<dd><p><var>p</var>: a pointer to Unicode character encoded as UTF-8
</p>
<p>Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
If  <code>p</code> does not point to a valid UTF-8 encoded character, results are
undefined.
</p>
<p>Return value: the resulting character.
</p></dd></dl>

<a name="stringprep_005fucs4_005fto_005futf8-1"></a>
<h4 class="subheading">stringprep_ucs4_to_utf8</h4>
<a name="stringprep_005fucs4_005fto_005futf8"></a><dl>
<dt><a name="index-stringprep_005fucs4_005fto_005futf8"></a>Function: <em>char *</em> <strong>stringprep_ucs4_to_utf8</strong> <em>(const uint32_t * <var>str</var>, ssize_t <var>len</var>, size_t * <var>items_read</var>, size_t * <var>items_written</var>)</em></dt>
<dd><p><var>str</var>: a UCS-4 encoded string
</p>
<p><var>len</var>: the maximum length of  <code>str</code> to use. If  <code>len</code> &lt; 0, then
the string is terminated with a 0 character.
</p>
<p><var>items_read</var>: location to store number of characters read read, or <code>NULL</code> .
</p>
<p><var>items_written</var>: location to store number of bytes written or <code>NULL</code> .
The value here stored does not include the trailing 0
byte.
</p>
<p>Convert a string from a 32-bit fixed width representation as UCS-4.
to UTF-8. The result will be terminated with a 0 byte.
</p>
<p>Return value: a pointer to a newly allocated UTF-8 string.
This value must be deallocated by the caller.
If an error occurs, <code>NULL</code>  will be returned.
</p></dd></dl>

<a name="stringprep_005futf8_005fto_005fucs4-1"></a>
<h4 class="subheading">stringprep_utf8_to_ucs4</h4>
<a name="stringprep_005futf8_005fto_005fucs4"></a><dl>
<dt><a name="index-stringprep_005futf8_005fto_005fucs4"></a>Function: <em>uint32_t *</em> <strong>stringprep_utf8_to_ucs4</strong> <em>(const char * <var>str</var>, ssize_t <var>len</var>, size_t * <var>items_written</var>)</em></dt>
<dd><p><var>str</var>: a UTF-8 encoded string
</p>
<p><var>len</var>: the maximum length of  <code>str</code> to use. If  <code>len</code> &lt; 0, then
the string is nul-terminated.
</p>
<p><var>items_written</var>: location to store the number of characters in the
result, or <code>NULL</code> .
</p>
<p>Convert a string from UTF-8 to a 32-bit fixed width representation
as UCS-4.  The function now performs error checking to verify that
the input is valid UTF-8 (before it was documented to not do error
checking).
</p>
<p>Return value: a pointer to a newly allocated UCS-4 string.
This value must be deallocated by the caller.
</p></dd></dl>


<a name="Unicode-Normalization"></a>
<h3 class="section">3.3 Unicode Normalization</h3>

<a name="stringprep_005fucs4_005fnfkc_005fnormalize-1"></a>
<h4 class="subheading">stringprep_ucs4_nfkc_normalize</h4>
<a name="stringprep_005fucs4_005fnfkc_005fnormalize"></a><dl>
<dt><a name="index-stringprep_005fucs4_005fnfkc_005fnormalize"></a>Function: <em>uint32_t *</em> <strong>stringprep_ucs4_nfkc_normalize</strong> <em>(const uint32_t * <var>str</var>, ssize_t <var>len</var>)</em></dt>
<dd><p><var>str</var>: a Unicode string.
</p>
<p><var>len</var>: length of  <code>str</code> array, or -1 if  <code>str</code> is nul-terminated.
</p>
<p>Converts a UCS4 string into canonical form, see
<code>stringprep_utf8_nfkc_normalize()</code>  for more information.
</p>
<p>Return value: a newly allocated Unicode string, that is the NFKC
normalized form of  <code>str</code> .
</p></dd></dl>

<a name="stringprep_005futf8_005fnfkc_005fnormalize-1"></a>
<h4 class="subheading">stringprep_utf8_nfkc_normalize</h4>
<a name="stringprep_005futf8_005fnfkc_005fnormalize"></a><dl>
<dt><a name="index-stringprep_005futf8_005fnfkc_005fnormalize"></a>Function: <em>char *</em> <strong>stringprep_utf8_nfkc_normalize</strong> <em>(const char * <var>str</var>, ssize_t <var>len</var>)</em></dt>
<dd><p><var>str</var>: a UTF-8 encoded string.
</p>
<p><var>len</var>: length of  <code>str</code> , in bytes, or -1 if  <code>str</code> is nul-terminated.
</p>
<p>Converts a string into canonical form, standardizing
such issues as whether a character with an accent
is represented as a base character and combining
accent or as a single precomposed character.
</p>
<p>The normalization mode is NFKC (ALL COMPOSE).  It standardizes
differences that do not affect the text content, such as the
above-mentioned accent representation. It standardizes the
&quot;compatibility&quot; characters in Unicode, such as SUPERSCRIPT THREE to
the standard forms (in this case DIGIT THREE). Formatting
information may be lost but for most text operations such
characters should be considered the same. It returns a result with
composed forms rather than a maximally decomposed form.
</p>
<p>Return value: a newly allocated string, that is the
NFKC normalized form of  <code>str</code> .
</p></dd></dl>


<a name="Character-Set-Conversion"></a>
<h3 class="section">3.4 Character Set Conversion</h3>

<a name="stringprep_005flocale_005fcharset-1"></a>
<h4 class="subheading">stringprep_locale_charset</h4>
<a name="stringprep_005flocale_005fcharset"></a><dl>
<dt><a name="index-stringprep_005flocale_005fcharset"></a>Function: <em>const char *</em> <strong>stringprep_locale_charset</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Find out current locale charset.  The function respect the CHARSET
environment variable, but typically uses nl_langinfo(CODESET) when
it is supported.  It fall back on &quot;ASCII&quot; if CHARSET isn&rsquo;t set and
nl_langinfo isn&rsquo;t supported or return anything.
</p>
<p>Note that this function return the application&rsquo;s locale&rsquo;s preferred
charset (or thread&rsquo;s locale&rsquo;s preffered charset, if your system
support thread-specific locales).  It does not return what the
system may be using.  Thus, if you receive data from external
sources you cannot in general use this function to guess what
charset it is encoded in.  Use stringprep_convert from the external
representation into the charset returned by this function, to have
data in the locale encoding.
</p>
<p>Return value: Return the character set used by the current locale.
It will never return NULL, but use &quot;ASCII&quot; as a fallback.
</p></dd></dl>

<a name="stringprep_005fconvert-1"></a>
<h4 class="subheading">stringprep_convert</h4>
<a name="stringprep_005fconvert"></a><dl>
<dt><a name="index-stringprep_005fconvert"></a>Function: <em>char *</em> <strong>stringprep_convert</strong> <em>(const char * <var>str</var>, const char * <var>to_codeset</var>, const char * <var>from_codeset</var>)</em></dt>
<dd><p><var>str</var>: input zero-terminated string.
</p>
<p><var>to_codeset</var>: name of destination character set.
</p>
<p><var>from_codeset</var>: name of origin character set, as used by  <code>str</code> .
</p>
<p>Convert the string from one character set to another using the
system&rsquo;s <code>iconv()</code>  function.
</p>
<p>Return value: Returns newly allocated zero-terminated string which
is  <code>str</code> transcoded into to_codeset.
</p></dd></dl>

<a name="stringprep_005flocale_005fto_005futf8-1"></a>
<h4 class="subheading">stringprep_locale_to_utf8</h4>
<a name="stringprep_005flocale_005fto_005futf8"></a><dl>
<dt><a name="index-stringprep_005flocale_005fto_005futf8"></a>Function: <em>char *</em> <strong>stringprep_locale_to_utf8</strong> <em>(const char * <var>str</var>)</em></dt>
<dd><p><var>str</var>: input zero terminated string.
</p>
<p>Convert string encoded in the locale&rsquo;s character set into UTF-8 by
using <code>stringprep_convert()</code> .
</p>
<p>Return value: Returns newly allocated zero-terminated string which
is  <code>str</code> transcoded into UTF-8.
</p></dd></dl>

<a name="stringprep_005futf8_005fto_005flocale-1"></a>
<h4 class="subheading">stringprep_utf8_to_locale</h4>
<a name="stringprep_005futf8_005fto_005flocale"></a><dl>
<dt><a name="index-stringprep_005futf8_005fto_005flocale"></a>Function: <em>char *</em> <strong>stringprep_utf8_to_locale</strong> <em>(const char * <var>str</var>)</em></dt>
<dd><p><var>str</var>: input zero terminated string.
</p>
<p>Convert string encoded in UTF-8 into the locale&rsquo;s character set by
using <code>stringprep_convert()</code> .
</p>
<p>Return value: Returns newly allocated zero-terminated string which
is  <code>str</code> transcoded into the locale&rsquo;s character set.
</p></dd></dl>



<hr>
<a name="Stringprep-Functions"></a>
<div class="header">
<p>
Next: <a href="#Punycode-Functions" accesskey="n" rel="next">Punycode Functions</a>, Previous: <a href="#Utility-Functions" accesskey="p" rel="prev">Utility Functions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Stringprep-Functions-1"></a>
<h2 class="chapter">4 Stringprep Functions</h2>
<a name="index-Stringprep-Functions"></a>

<p>Stringprep describes a framework for preparing Unicode text strings in
order to increase the likelihood that string input and string
comparison work in ways that make sense for typical users throughout
the world. The stringprep protocol is useful for protocol identifier
values, company and personal names, internationalized domain names,
and other text strings.
</p>
<a name="Header-file-stringprep_002eh-1"></a>
<h3 class="section">4.1 Header file <code>stringprep.h</code></h3>

<p>To use the functions explained in this chapter, you need to include
the file <samp>stringprep.h</samp> using:
</p>
<div class="example">
<pre class="example">#include &lt;stringprep.h&gt;
</pre></div>

<a name="Defining-A-Stringprep-Profile"></a>
<h3 class="section">4.2 Defining A Stringprep Profile</h3>

<p>Further types and structures are defined for applications that want to
specify their own stringprep profile.  As these are fairly obscure,
and by necessity tied to the implementation, we do not document them
here.  Look into the <samp>stringprep.h</samp> header file, and the
<samp>profiles.c</samp> source code for the details.
</p>
<a name="Control-Flags"></a>
<h3 class="section">4.3 Control Flags</h3>

<dl>
<dt><a name="index-STRINGPREP_005fNO_005fNFKC"></a>Stringprep flags: <em>Stringprep_profile_flags</em> <strong>STRINGPREP_NO_NFKC</strong></dt>
<dd><p>Disable the NFKC normalization, as well as selecting the non-NFKC case
folding tables.  Usually the profile specifies BIDI and NFKC settings,
and applications should not override it unless in special situations.
</p></dd></dl>

<dl>
<dt><a name="index-STRINGPREP_005fNO_005fBIDI"></a>Stringprep flags: <em>Stringprep_profile_flags</em> <strong>STRINGPREP_NO_BIDI</strong></dt>
<dd><p>Disable the BIDI step.  Usually the profile specifies BIDI and NFKC
settings, and applications should not override it unless in special
situations.
</p></dd></dl>

<dl>
<dt><a name="index-STRINGPREP_005fNO_005fUNASSIGNED"></a>Stringprep flags: <em>Stringprep_profile_flags</em> <strong>STRINGPREP_NO_UNASSIGNED</strong></dt>
<dd><p>Make the library return with an error if string contains unassigned
characters according to profile.
</p></dd></dl>

<a name="Core-Functions"></a>
<h3 class="section">4.4 Core Functions</h3>

<a name="stringprep_005f4i-1"></a>
<h4 class="subheading">stringprep_4i</h4>
<a name="stringprep_005f4i"></a><dl>
<dt><a name="index-stringprep_005f4i"></a>Function: <em>int</em> <strong>stringprep_4i</strong> <em>(uint32_t * <var>ucs4</var>, size_t * <var>len</var>, size_t <var>maxucs4len</var>, Stringprep_profile_flags <var>flags</var>, const Stringprep_profile * <var>profile</var>)</em></dt>
<dd><p><var>ucs4</var>: input/output array with string to prepare.
</p>
<p><var>len</var>: on input, length of input array with Unicode code points,
on exit, length of output array with Unicode code points.
</p>
<p><var>maxucs4len</var>: maximum length of input/output array.
</p>
<p><var>flags</var>: a <code>Stringprep_profile_flags</code>  value, or 0.
</p>
<p><var>profile</var>: pointer to <code>Stringprep_profile</code>  to use.
</p>
<p>Prepare the input UCS-4 string according to the stringprep profile,
and write back the result to the input string.
</p>
<p>The input is not required to be zero terminated ( <code>ucs4</code> [ <code>len</code> ] = 0).
The output will not be zero terminated unless  <code>ucs4</code> [ <code>len</code> ] = 0.
Instead, see <code>stringprep_4zi()</code>  if your input is zero terminated or
if you want the output to be.
</p>
<p>Since the stringprep operation can expand the string,  <code>maxucs4len</code> indicate how large the buffer holding the string is.  This function
will not read or write to code points outside that size.
</p>
<p>The  <code>flags</code> are one of <code>Stringprep_profile_flags</code>  values, or 0.
</p>
<p>The  <code>profile</code> contain the <code>Stringprep_profile</code>  instructions to
perform.  Your application can define new profiles, possibly
re-using the generic stringprep tables that always will be part of
the library, or use one of the currently supported profiles.
</p>
<p>Return value: Returns <code>STRINGPREP_OK</code>  iff successful, or an
<code>Stringprep_rc</code>  error code.
</p></dd></dl>

<a name="stringprep_005f4zi-1"></a>
<h4 class="subheading">stringprep_4zi</h4>
<a name="stringprep_005f4zi"></a><dl>
<dt><a name="index-stringprep_005f4zi"></a>Function: <em>int</em> <strong>stringprep_4zi</strong> <em>(uint32_t * <var>ucs4</var>, size_t <var>maxucs4len</var>, Stringprep_profile_flags <var>flags</var>, const Stringprep_profile * <var>profile</var>)</em></dt>
<dd><p><var>ucs4</var>: input/output array with zero terminated string to prepare.
</p>
<p><var>maxucs4len</var>: maximum length of input/output array.
</p>
<p><var>flags</var>: a <code>Stringprep_profile_flags</code>  value, or 0.
</p>
<p><var>profile</var>: pointer to <code>Stringprep_profile</code>  to use.
</p>
<p>Prepare the input zero terminated UCS-4 string according to the
stringprep profile, and write back the result to the input string.
</p>
<p>Since the stringprep operation can expand the string,  <code>maxucs4len</code> indicate how large the buffer holding the string is.  This function
will not read or write to code points outside that size.
</p>
<p>The  <code>flags</code> are one of <code>Stringprep_profile_flags</code>  values, or 0.
</p>
<p>The  <code>profile</code> contain the <code>Stringprep_profile</code>  instructions to
perform.  Your application can define new profiles, possibly
re-using the generic stringprep tables that always will be part of
the library, or use one of the currently supported profiles.
</p>
<p>Return value: Returns <code>STRINGPREP_OK</code>  iff successful, or an
<code>Stringprep_rc</code>  error code.
</p></dd></dl>

<a name="stringprep-1"></a>
<h4 class="subheading">stringprep</h4>
<a name="stringprep"></a><dl>
<dt><a name="index-stringprep"></a>Function: <em>int</em> <strong>stringprep</strong> <em>(char * <var>in</var>, size_t <var>maxlen</var>, Stringprep_profile_flags <var>flags</var>, const Stringprep_profile * <var>profile</var>)</em></dt>
<dd><p><var>in</var>: input/ouput array with string to prepare.
</p>
<p><var>maxlen</var>: maximum length of input/output array.
</p>
<p><var>flags</var>: a <code>Stringprep_profile_flags</code>  value, or 0.
</p>
<p><var>profile</var>: pointer to <code>Stringprep_profile</code>  to use.
</p>
<p>Prepare the input zero terminated UTF-8 string according to the
stringprep profile, and write back the result to the input string.
</p>
<p>Note that you must convert strings entered in the systems locale
into UTF-8 before using this function, see
<code>stringprep_locale_to_utf8()</code> .
</p>
<p>Since the stringprep operation can expand the string,  <code>maxlen</code> indicate how large the buffer holding the string is.  This function
will not read or write to characters outside that size.
</p>
<p>The  <code>flags</code> are one of <code>Stringprep_profile_flags</code>  values, or 0.
</p>
<p>The  <code>profile</code> contain the <code>Stringprep_profile</code>  instructions to
perform.  Your application can define new profiles, possibly
re-using the generic stringprep tables that always will be part of
the library, or use one of the currently supported profiles.
</p>
<p>Return value: Returns <code>STRINGPREP_OK</code>  iff successful, or an error code.
</p></dd></dl>

<a name="stringprep_005fprofile-1"></a>
<h4 class="subheading">stringprep_profile</h4>
<a name="stringprep_005fprofile"></a><dl>
<dt><a name="index-stringprep_005fprofile"></a>Function: <em>int</em> <strong>stringprep_profile</strong> <em>(const char * <var>in</var>, char ** <var>out</var>, const char * <var>profile</var>, Stringprep_profile_flags <var>flags</var>)</em></dt>
<dd><p><var>in</var>: input array with UTF-8 string to prepare.
</p>
<p><var>out</var>: output variable with pointer to newly allocate string.
</p>
<p><var>profile</var>: name of stringprep profile to use.
</p>
<p><var>flags</var>: a <code>Stringprep_profile_flags</code>  value, or 0.
</p>
<p>Prepare the input zero terminated UTF-8 string according to the
stringprep profile, and return the result in a newly allocated
variable.
</p>
<p>Note that you must convert strings entered in the systems locale
into UTF-8 before using this function, see
<code>stringprep_locale_to_utf8()</code> .
</p>
<p>The output  <code>out</code> variable must be deallocated by the caller.
</p>
<p>The  <code>flags</code> are one of <code>Stringprep_profile_flags</code>  values, or 0.
</p>
<p>The  <code>profile</code> specifies the name of the stringprep profile to use.
It must be one of the internally supported stringprep profiles.
</p>
<p>Return value: Returns <code>STRINGPREP_OK</code>  iff successful, or an error code.
</p></dd></dl>


<a name="Error-Handling"></a>
<h3 class="section">4.5 Error Handling</h3>

<a name="stringprep_005fstrerror-1"></a>
<h4 class="subheading">stringprep_strerror</h4>
<a name="stringprep_005fstrerror"></a><dl>
<dt><a name="index-stringprep_005fstrerror"></a>Function: <em>const char *</em> <strong>stringprep_strerror</strong> <em>(Stringprep_rc <var>rc</var>)</em></dt>
<dd><p><var>rc</var>: a <code>Stringprep_rc</code>  return code.
</p>
<p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.
</p>
<p><strong>STRINGPREP_OK:</strong> Successful operation.  This value is guaranteed to
always be zero, the remaining ones are only guaranteed to hold
non-zero values, for logical comparison purposes.
</p>
<p><strong>STRINGPREP_CONTAINS_UNASSIGNED:</strong> String contain unassigned Unicode
code points, which is forbidden by the profile.
</p>
<p><strong>STRINGPREP_CONTAINS_PROHIBITED:</strong> String contain code points
prohibited by the profile.
</p>
<p><strong>STRINGPREP_BIDI_BOTH_L_AND_RAL:</strong> String contain code points with
conflicting bidirection category.
</p>
<p><strong>STRINGPREP_BIDI_LEADTRAIL_NOT_RAL:</strong> Leading and trailing character
in string not of proper bidirectional category.
</p>
<p><strong>STRINGPREP_BIDI_CONTAINS_PROHIBITED:</strong> Contains prohibited code
points detected by bidirectional code.
</p>
<p><strong>STRINGPREP_TOO_SMALL_BUFFER:</strong> Buffer handed to function was too
small.  This usually indicate a problem in the calling
application.
</p>
<p><strong>STRINGPREP_PROFILE_ERROR:</strong> The stringprep profile was inconsistent.
This usually indicate an internal error in the library.
</p>
<p><strong>STRINGPREP_FLAG_ERROR:</strong> The supplied flag conflicted with profile.
This usually indicate a problem in the calling application.
</p>
<p><strong>STRINGPREP_UNKNOWN_PROFILE:</strong> The supplied profile name was not
known to the library.
</p>
<p><strong>STRINGPREP_ICONV_ERROR:</strong> Could not convert string in locale encoding.
</p>
<p><strong>STRINGPREP_NFKC_FAILED:</strong> The Unicode NFKC operation failed.  This
usually indicate an internal error in the library.
</p>
<p><strong>STRINGPREP_MALLOC_ERROR:</strong> The <code>malloc()</code>  was out of memory.  This is
usually a fatal error.
</p>
<p>Return value: Returns a pointer to a statically allocated string
containing a description of the error with the return code  <code>rc</code> .
</p></dd></dl>


<a name="Stringprep-Profile-Macros"></a>
<h3 class="section">4.6 Stringprep Profile Macros</h3>

<dl>
<dt><a name="index-stringprep_005fnameprep_005fno_005funassigned"></a>Function: <em>int</em> <strong>stringprep_nameprep_no_unassigned</strong> <em>(char * <var>in</var>, int <var>maxlen</var>)</em></dt>
<dd>
<p><var>in</var>: input/ouput array with string to prepare.
</p>
<p><var>maxlen</var>: maximum length of input/output array.
</p>
<p>Prepare the input UTF-8 string according to the nameprep profile.  The
AllowUnassigned flag is false, use <code>stringprep_nameprep</code> for
true AllowUnassigned.  Returns 0 iff successful, or an error code.
</p></dd></dl>

<dl>
<dt><a name="index-stringprep_005fiscsi"></a>Function: <em>int</em> <strong>stringprep_iscsi</strong> <em>(char * <var>in</var>, int <var>maxlen</var>)</em></dt>
<dd>
<p><var>in</var>: input/ouput array with string to prepare.
</p>
<p><var>maxlen</var>: maximum length of input/output array.
</p>
<p>Prepare the input UTF-8 string according to the draft iSCSI stringprep
profile.  Returns 0 iff successful, or an error code.
</p></dd></dl>

<dl>
<dt><a name="index-stringprep_005fplain"></a>Function: <em>int</em> <strong>stringprep_plain</strong> <em>(char * <var>in</var>, int <var>maxlen</var>)</em></dt>
<dd>
<p><var>in</var>: input/ouput array with string to prepare.
</p>
<p><var>maxlen</var>: maximum length of input/output array.
</p>
<p>Prepare the input UTF-8 string according to the draft SASL ANONYMOUS
profile.  Returns 0 iff successful, or an error code.
</p></dd></dl>

<dl>
<dt><a name="index-stringprep_005fxmpp_005fnodeprep"></a>Function: <em>int</em> <strong>stringprep_xmpp_nodeprep</strong> <em>(char * <var>in</var>, int <var>maxlen</var>)</em></dt>
<dd>
<p><var>in</var>: input/ouput array with string to prepare.
</p>
<p><var>maxlen</var>: maximum length of input/output array.
</p>
<p>Prepare the input UTF-8 string according to the draft XMPP node
identifier profile.  Returns 0 iff successful, or an error code.
</p></dd></dl>

<dl>
<dt><a name="index-stringprep_005fxmpp_005fresourceprep"></a>Function: <em>int</em> <strong>stringprep_xmpp_resourceprep</strong> <em>(char * <var>in</var>, int <var>maxlen</var>)</em></dt>
<dd>
<p><var>in</var>: input/ouput array with string to prepare.
</p>
<p><var>maxlen</var>: maximum length of input/output array.
</p>
<p>Prepare the input UTF-8 string according to the draft XMPP resource
identifier profile.  Returns 0 iff successful, or an error code.
</p></dd></dl>

<hr>
<a name="Punycode-Functions"></a>
<div class="header">
<p>
Next: <a href="#IDNA-Functions" accesskey="n" rel="next">IDNA Functions</a>, Previous: <a href="#Stringprep-Functions" accesskey="p" rel="prev">Stringprep Functions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Punycode-Functions-1"></a>
<h2 class="chapter">5 Punycode Functions</h2>
<a name="index-Punycode-Functions"></a>

<p>Punycode is a simple and efficient transfer encoding syntax designed
for use with Internationalized Domain Names in Applications. It
uniquely and reversibly transforms a Unicode string into an ASCII
string. ASCII characters in the Unicode string are represented
literally, and non-ASCII characters are represented by ASCII
characters that are allowed in host name labels (letters, digits, and
hyphens). A general algorithm called Bootstring allows a string of
basic code points to uniquely represent any string of code points
drawn from a larger set. Punycode is an instance of Bootstring that
uses particular parameter values, appropriate for IDNA.
</p>
<a name="Header-file-punycode_002eh"></a>
<h3 class="section">5.1 Header file <code>punycode.h</code></h3>

<p>To use the functions explained in this chapter, you need to include
the file <samp>punycode.h</samp> using:
</p>
<div class="example">
<pre class="example">#include &lt;punycode.h&gt;
</pre></div>

<a name="Unicode-Code-Point-Data-Type"></a>
<h3 class="section">5.2 Unicode Code Point Data Type</h3>

<p>The punycode function uses a special type to denote Unicode code
points.  It is guaranteed to always be a 32 bit unsigned integer.
</p>
<dl>
<dt><a name="index-punycode_005fuint"></a>Punycode Unicode code point: <em>uint32_t</em> <strong>punycode_uint</strong></dt>
<dd><p>A unsigned integer that hold Unicode code points.
</p></dd></dl>

<a name="Core-Functions-1"></a>
<h3 class="section">5.3 Core Functions</h3>

<p>Note that the current implementation will fail if the
<code>input_length</code> exceed 4294967295 (the size of
<code>punycode_uint</code>).  This restriction may be removed in the future.
Meanwhile applications are encouraged to not depend on this problem,
and use <code>sizeof</code> to initialize <code>input_length</code> and
<code>output_length</code>.
</p>
<p>The functions provided are the following two entry points:
</p>
<a name="punycode_005fencode-1"></a>
<h4 class="subheading">punycode_encode</h4>
<a name="punycode_005fencode"></a><dl>
<dt><a name="index-punycode_005fencode"></a>Function: <em>int</em> <strong>punycode_encode</strong> <em>(size_t <var>input_length</var>, const punycode_uint [] <var>input</var>, const unsigned char [] <var>case_flags</var>, size_t * <var>output_length</var>, char [] <var>output</var>)</em></dt>
<dd><p><var>input_length</var>: The number of code points in the  <code>input</code> array and
the number of flags in the  <code>case_flags</code> array.
</p>
<p><var>input</var>: An array of code points.  They are presumed to be Unicode
code points, but that is not strictly REQUIRED.  The array
contains code points, not code units.  UTF-16 uses code units
D800 through DFFF to refer to code points 10000..10FFFF.  The
code points D800..DFFF do not occur in any valid Unicode string.
The code points that can occur in Unicode strings (0..D7FF and
E000..10FFFF) are also called Unicode scalar values.
</p>
<p><var>case_flags</var>: A <code>NULL</code>  pointer or an array of boolean values parallel
to the  <code>input</code> array.  Nonzero (true, flagged) suggests that the
corresponding Unicode character be forced to uppercase after
being decoded (if possible), and zero (false, unflagged) suggests
that it be forced to lowercase (if possible).  ASCII code points
(0..7F) are encoded literally, except that ASCII letters are
forced to uppercase or lowercase according to the corresponding
case flags.  If  <code>case_flags</code> is a <code>NULL</code>  pointer then ASCII letters
are left as they are, and other code points are treated as
unflagged.
</p>
<p><var>output_length</var>: The caller passes in the maximum number of ASCII
code points that it can receive.  On successful return it will
contain the number of ASCII code points actually output.
</p>
<p><var>output</var>: An array of ASCII code points.  It is *not*
null-terminated; it will contain zeros if and only if the  <code>input</code> contains zeros.  (Of course the caller can leave room for a
terminator and add one if needed.)
</p>
<p>Converts a sequence of code points (presumed to be Unicode code
points) to Punycode.
</p>
<p>Return value: The return value can be any of the <code>Punycode_status</code> 
values defined above except <code>PUNYCODE_BAD_INPUT</code> .  If not
<code>PUNYCODE_SUCCESS</code> , then  <code>output_size</code> and  <code>output</code> might contain
garbage.
</p></dd></dl>

<a name="punycode_005fdecode-1"></a>
<h4 class="subheading">punycode_decode</h4>
<a name="punycode_005fdecode"></a><dl>
<dt><a name="index-punycode_005fdecode"></a>Function: <em>int</em> <strong>punycode_decode</strong> <em>(size_t <var>input_length</var>, const char [] <var>input</var>, size_t * <var>output_length</var>, punycode_uint [] <var>output</var>, unsigned char [] <var>case_flags</var>)</em></dt>
<dd><p><var>input_length</var>: The number of ASCII code points in the  <code>input</code> array.
</p>
<p><var>input</var>: An array of ASCII code points (0..7F).
</p>
<p><var>output_length</var>: The caller passes in the maximum number of code
points that it can receive into the  <code>output</code> array (which is also
the maximum number of flags that it can receive into the
 <code>case_flags</code> array, if  <code>case_flags</code> is not a <code>NULL</code>  pointer).  On
successful return it will contain the number of code points
actually output (which is also the number of flags actually
output, if case_flags is not a null pointer).  The decoder will
never need to output more code points than the number of ASCII
code points in the input, because of the way the encoding is
defined.  The number of code points output cannot exceed the
maximum possible value of a punycode_uint, even if the supplied
 <code>output_length</code> is greater than that.
</p>
<p><var>output</var>: An array of code points like the input argument of
<code>punycode_encode()</code>  (see above).
</p>
<p><var>case_flags</var>: A <code>NULL</code>  pointer (if the flags are not needed by the
caller) or an array of boolean values parallel to the  <code>output</code> array.  Nonzero (true, flagged) suggests that the corresponding
Unicode character be forced to uppercase by the caller (if
possible), and zero (false, unflagged) suggests that it be forced
to lowercase (if possible).  ASCII code points (0..7F) are output
already in the proper case, but their flags will be set
appropriately so that applying the flags would be harmless.
</p>
<p>Converts Punycode to a sequence of code points (presumed to be
Unicode code points).
</p>
<p>Return value: The return value can be any of the <code>Punycode_status</code> 
values defined above.  If not <code>PUNYCODE_SUCCESS</code> , then
 <code>output_length</code> ,  <code>output</code> , and  <code>case_flags</code> might contain garbage.
</p></dd></dl>


<a name="Error-Handling-1"></a>
<h3 class="section">5.4 Error Handling</h3>

<a name="punycode_005fstrerror-1"></a>
<h4 class="subheading">punycode_strerror</h4>
<a name="punycode_005fstrerror"></a><dl>
<dt><a name="index-punycode_005fstrerror"></a>Function: <em>const char *</em> <strong>punycode_strerror</strong> <em>(Punycode_status <var>rc</var>)</em></dt>
<dd><p><var>rc</var>: an <code>Punycode_status</code>  return code.
</p>
<p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.
</p>
<p><strong>PUNYCODE_SUCCESS:</strong> Successful operation.  This value is guaranteed
to always be zero, the remaining ones are only guaranteed to hold
non-zero values, for logical comparison purposes.
</p>
<p><strong>PUNYCODE_BAD_INPUT:</strong> Input is invalid.
</p>
<p><strong>PUNYCODE_BIG_OUTPUT:</strong> Output would exceed the space provided.
</p>
<p><strong>PUNYCODE_OVERFLOW:</strong> Input needs wider integers to process.
</p>
<p>Return value: Returns a pointer to a statically allocated string
containing a description of the error with the return code  <code>rc</code> .
</p></dd></dl>


<hr>
<a name="IDNA-Functions"></a>
<div class="header">
<p>
Next: <a href="#TLD-Functions" accesskey="n" rel="next">TLD Functions</a>, Previous: <a href="#Punycode-Functions" accesskey="p" rel="prev">Punycode Functions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="IDNA-Functions-1"></a>
<h2 class="chapter">6 IDNA Functions</h2>
<a name="index-IDNA-Functions"></a>

<p>Until now, there has been no standard method for domain names to use
characters outside the ASCII repertoire. The IDNA document defines
internationalized domain names (IDNs) and a mechanism called IDNA for
handling them in a standard fashion. IDNs use characters drawn from a
large repertoire (Unicode), but IDNA allows the non-ASCII characters
to be represented using only the ASCII characters already allowed in
so-called host names today. This backward-compatible representation is
required in existing protocols like DNS, so that IDNs can be
introduced with no changes to the existing infrastructure. IDNA is
only meant for processing domain names, not free text.
</p>
<a name="Header-file-idna_002eh"></a>
<h3 class="section">6.1 Header file <code>idna.h</code></h3>

<p>To use the functions explained in this chapter, you need to include
the file <samp>idna.h</samp> using:
</p>
<div class="example">
<pre class="example">#include &lt;idna.h&gt;
</pre></div>

<a name="Control-Flags-1"></a>
<h3 class="section">6.2 Control Flags</h3>

<p>The IDNA <code>flags</code> parameter can take on the following values, or a
bit-wise inclusive or of any subset of the parameters:
</p>
<dl>
<dt><a name="index-IDNA_005fALLOW_005fUNASSIGNED"></a>Return code: <em>Idna_flags</em> <strong>IDNA_ALLOW_UNASSIGNED</strong></dt>
<dd><p>Allow unassigned Unicode code points.
</p></dd></dl>

<dl>
<dt><a name="index-IDNA_005fUSE_005fSTD3_005fASCII_005fRULES"></a>Return code: <em>Idna_flags</em> <strong>IDNA_USE_STD3_ASCII_RULES</strong></dt>
<dd><p>Check output to make sure it is a STD3 conforming host name.
</p></dd></dl>

<a name="Prefix-String"></a>
<h3 class="section">6.3 Prefix String</h3>

<dl>
<dt><a name="index-IDNA_005fACE_005fPREFIX"></a>Macro: <em>#define</em> <strong>IDNA_ACE_PREFIX</strong></dt>
<dd><p>String with the official IDNA prefix, <code>xn--</code>.
</p></dd></dl>

<a name="Core-Functions-2"></a>
<h3 class="section">6.4 Core Functions</h3>

<p>The idea behind the IDNA function names are as follows: the
<code>idna_to_ascii_4i</code> and <code>idna_to_unicode_44i</code> functions are
the core IDNA primitives.  The <code>4</code> indicate that the function
takes UCS-4 strings (i.e., Unicode code points encoded in a 32-bit
unsigned integer type) of the specified length.  The <code>i</code> indicate
that the data is written &ldquo;inline&rdquo; into the buffer.  This means the
caller is responsible for allocating (and de-allocating) the string,
and providing the library with the allocated length of the string.
The output length is written in the output length variable.  The
remaining functions all contain the <code>z</code> indicator, which means
the strings are zero terminated.  All output strings are allocated by
the library, and must be de-allocated by the caller.  The <code>4</code>
indicator again means that the string is UCS-4, the <code>8</code> means the
strings are UTF-8 and the <code>l</code> indicator means the strings are
encoded in the encoding used by the current locale.
</p>
<p>The functions provided are the following entry points:
</p>
<a name="idna_005fto_005fascii_005f4i-1"></a>
<h4 class="subheading">idna_to_ascii_4i</h4>
<a name="idna_005fto_005fascii_005f4i"></a><dl>
<dt><a name="index-idna_005fto_005fascii_005f4i"></a>Function: <em>int</em> <strong>idna_to_ascii_4i</strong> <em>(const uint32_t * <var>in</var>, size_t <var>inlen</var>, char * <var>out</var>, int <var>flags</var>)</em></dt>
<dd><p><var>in</var>: input array with unicode code points.
</p>
<p><var>inlen</var>: length of input array with unicode code points.
</p>
<p><var>out</var>: output zero terminated string that must have room for at
least 63 characters plus the terminating zero.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>The ToASCII operation takes a sequence of Unicode code points that
make up one domain label and transforms it into a sequence of code
points in the ASCII range (0..7F). If ToASCII succeeds, the
original sequence and the resulting sequence are equivalent labels.
</p>
<p>It is important to note that the ToASCII operation can fail. ToASCII
fails if any step of it fails. If any step of the ToASCII operation
fails on any label in a domain name, that domain name MUST NOT be used
as an internationalized domain name. The method for deadling with this
failure is application-specific.
</p>
<p>The inputs to ToASCII are a sequence of code points, the AllowUnassigned
flag, and the UseSTD3ASCIIRules flag. The output of ToASCII is either a
sequence of ASCII code points or a failure condition.
</p>
<p>ToASCII never alters a sequence of code points that are all in the ASCII
range to begin with (although it could fail). Applying the ToASCII
operation multiple times has exactly the same effect as applying it just
once.
</p>
<p>Return value: Returns 0 on success, or an <code>Idna_rc</code>  error code.
</p></dd></dl>

<a name="idna_005fto_005funicode_005f44i-1"></a>
<h4 class="subheading">idna_to_unicode_44i</h4>
<a name="idna_005fto_005funicode_005f44i"></a><dl>
<dt><a name="index-idna_005fto_005funicode_005f44i"></a>Function: <em>int</em> <strong>idna_to_unicode_44i</strong> <em>(const uint32_t * <var>in</var>, size_t <var>inlen</var>, uint32_t * <var>out</var>, size_t * <var>outlen</var>, int <var>flags</var>)</em></dt>
<dd><p><var>in</var>: input array with unicode code points.
</p>
<p><var>inlen</var>: length of input array with unicode code points.
</p>
<p><var>out</var>: output array with unicode code points.
</p>
<p><var>outlen</var>: on input, maximum size of output array with unicode code points,
on exit, actual size of output array with unicode code points.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>The ToUnicode operation takes a sequence of Unicode code points
that make up one domain label and returns a sequence of Unicode
code points. If the input sequence is a label in ACE form, then the
result is an equivalent internationalized label that is not in ACE
form, otherwise the original sequence is returned unaltered.
</p>
<p>ToUnicode never fails. If any step fails, then the original input
sequence is returned immediately in that step.
</p>
<p>The Punycode decoder can never output more code points than it
inputs, but Nameprep can, and therefore ToUnicode can.  Note that
the number of octets needed to represent a sequence of code points
depends on the particular character encoding used.
</p>
<p>The inputs to ToUnicode are a sequence of code points, the
AllowUnassigned flag, and the UseSTD3ASCIIRules flag. The output of
ToUnicode is always a sequence of Unicode code points.
</p>
<p>Return value: Returns <code>Idna_rc</code>  error condition, but it must only be
used for debugging purposes.  The output buffer is always
guaranteed to contain the correct data according to the
specification (sans malloc induced errors).  NB!  This means that
you normally ignore the return code from this function, as
checking it means breaking the standard.
</p></dd></dl>


<a name="Simplified-ToASCII-Interface"></a>
<h3 class="section">6.5 Simplified ToASCII Interface</h3>

<a name="idna_005fto_005fascii_005f4z-1"></a>
<h4 class="subheading">idna_to_ascii_4z</h4>
<a name="idna_005fto_005fascii_005f4z"></a><dl>
<dt><a name="index-idna_005fto_005fascii_005f4z"></a>Function: <em>int</em> <strong>idna_to_ascii_4z</strong> <em>(const uint32_t * <var>input</var>, char ** <var>output</var>, int <var>flags</var>)</em></dt>
<dd><p><var>input</var>: zero terminated input Unicode string.
</p>
<p><var>output</var>: pointer to newly allocated output string.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>Convert UCS-4 domain name to ASCII string.  The domain name may
contain several labels, separated by dots.  The output buffer must
be deallocated by the caller.
</p>
<p>Return value: Returns <code>IDNA_SUCCESS</code>  on success, or error code.
</p></dd></dl>

<a name="idna_005fto_005fascii_005f8z-1"></a>
<h4 class="subheading">idna_to_ascii_8z</h4>
<a name="idna_005fto_005fascii_005f8z"></a><dl>
<dt><a name="index-idna_005fto_005fascii_005f8z"></a>Function: <em>int</em> <strong>idna_to_ascii_8z</strong> <em>(const char * <var>input</var>, char ** <var>output</var>, int <var>flags</var>)</em></dt>
<dd><p><var>input</var>: zero terminated input UTF-8 string.
</p>
<p><var>output</var>: pointer to newly allocated output string.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>Convert UTF-8 domain name to ASCII string.  The domain name may
contain several labels, separated by dots.  The output buffer must
be deallocated by the caller.
</p>
<p>Return value: Returns <code>IDNA_SUCCESS</code>  on success, or error code.
</p></dd></dl>

<a name="idna_005fto_005fascii_005flz-1"></a>
<h4 class="subheading">idna_to_ascii_lz</h4>
<a name="idna_005fto_005fascii_005flz"></a><dl>
<dt><a name="index-idna_005fto_005fascii_005flz"></a>Function: <em>int</em> <strong>idna_to_ascii_lz</strong> <em>(const char * <var>input</var>, char ** <var>output</var>, int <var>flags</var>)</em></dt>
<dd><p><var>input</var>: zero terminated input string encoded in the current locale&rsquo;s
character set.
</p>
<p><var>output</var>: pointer to newly allocated output string.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>Convert domain name in the locale&rsquo;s encoding to ASCII string.  The
domain name may contain several labels, separated by dots.  The
output buffer must be deallocated by the caller.
</p>
<p>Return value: Returns <code>IDNA_SUCCESS</code>  on success, or error code.
</p></dd></dl>


<a name="Simplified-ToUnicode-Interface"></a>
<h3 class="section">6.6 Simplified ToUnicode Interface</h3>

<a name="idna_005fto_005funicode_005f4z4z-1"></a>
<h4 class="subheading">idna_to_unicode_4z4z</h4>
<a name="idna_005fto_005funicode_005f4z4z"></a><dl>
<dt><a name="index-idna_005fto_005funicode_005f4z4z"></a>Function: <em>int</em> <strong>idna_to_unicode_4z4z</strong> <em>(const uint32_t * <var>input</var>, uint32_t ** <var>output</var>, int <var>flags</var>)</em></dt>
<dd><p><var>input</var>: zero-terminated Unicode string.
</p>
<p><var>output</var>: pointer to newly allocated output Unicode string.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>Convert possibly ACE encoded domain name in UCS-4 format into a
UCS-4 string.  The domain name may contain several labels,
separated by dots.  The output buffer must be deallocated by the
caller.
</p>
<p>Return value: Returns <code>IDNA_SUCCESS</code>  on success, or error code.
</p></dd></dl>

<a name="idna_005fto_005funicode_005f8z4z-1"></a>
<h4 class="subheading">idna_to_unicode_8z4z</h4>
<a name="idna_005fto_005funicode_005f8z4z"></a><dl>
<dt><a name="index-idna_005fto_005funicode_005f8z4z"></a>Function: <em>int</em> <strong>idna_to_unicode_8z4z</strong> <em>(const char * <var>input</var>, uint32_t ** <var>output</var>, int <var>flags</var>)</em></dt>
<dd><p><var>input</var>: zero-terminated UTF-8 string.
</p>
<p><var>output</var>: pointer to newly allocated output Unicode string.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>Convert possibly ACE encoded domain name in UTF-8 format into a
UCS-4 string.  The domain name may contain several labels,
separated by dots.  The output buffer must be deallocated by the
caller.
</p>
<p>Return value: Returns <code>IDNA_SUCCESS</code>  on success, or error code.
</p></dd></dl>

<a name="idna_005fto_005funicode_005f8z8z-1"></a>
<h4 class="subheading">idna_to_unicode_8z8z</h4>
<a name="idna_005fto_005funicode_005f8z8z"></a><dl>
<dt><a name="index-idna_005fto_005funicode_005f8z8z"></a>Function: <em>int</em> <strong>idna_to_unicode_8z8z</strong> <em>(const char * <var>input</var>, char ** <var>output</var>, int <var>flags</var>)</em></dt>
<dd><p><var>input</var>: zero-terminated UTF-8 string.
</p>
<p><var>output</var>: pointer to newly allocated output UTF-8 string.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>Convert possibly ACE encoded domain name in UTF-8 format into a
UTF-8 string.  The domain name may contain several labels,
separated by dots.  The output buffer must be deallocated by the
caller.
</p>
<p>Return value: Returns <code>IDNA_SUCCESS</code>  on success, or error code.
</p></dd></dl>

<a name="idna_005fto_005funicode_005f8zlz-1"></a>
<h4 class="subheading">idna_to_unicode_8zlz</h4>
<a name="idna_005fto_005funicode_005f8zlz"></a><dl>
<dt><a name="index-idna_005fto_005funicode_005f8zlz"></a>Function: <em>int</em> <strong>idna_to_unicode_8zlz</strong> <em>(const char * <var>input</var>, char ** <var>output</var>, int <var>flags</var>)</em></dt>
<dd><p><var>input</var>: zero-terminated UTF-8 string.
</p>
<p><var>output</var>: pointer to newly allocated output string encoded in the
current locale&rsquo;s character set.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>Convert possibly ACE encoded domain name in UTF-8 format into a
string encoded in the current locale&rsquo;s character set.  The domain
name may contain several labels, separated by dots.  The output
buffer must be deallocated by the caller.
</p>
<p>Return value: Returns <code>IDNA_SUCCESS</code>  on success, or error code.
</p></dd></dl>

<a name="idna_005fto_005funicode_005flzlz-1"></a>
<h4 class="subheading">idna_to_unicode_lzlz</h4>
<a name="idna_005fto_005funicode_005flzlz"></a><dl>
<dt><a name="index-idna_005fto_005funicode_005flzlz"></a>Function: <em>int</em> <strong>idna_to_unicode_lzlz</strong> <em>(const char * <var>input</var>, char ** <var>output</var>, int <var>flags</var>)</em></dt>
<dd><p><var>input</var>: zero-terminated string encoded in the current locale&rsquo;s
character set.
</p>
<p><var>output</var>: pointer to newly allocated output string encoded in the
current locale&rsquo;s character set.
</p>
<p><var>flags</var>: an <code>Idna_flags</code>  value, e.g., <code>IDNA_ALLOW_UNASSIGNED</code>  or
<code>IDNA_USE_STD3_ASCII_RULES</code> .
</p>
<p>Convert possibly ACE encoded domain name in the locale&rsquo;s character
set into a string encoded in the current locale&rsquo;s character set.
The domain name may contain several labels, separated by dots.  The
output buffer must be deallocated by the caller.
</p>
<p>Return value: Returns <code>IDNA_SUCCESS</code>  on success, or error code.
</p></dd></dl>


<a name="Error-Handling-2"></a>
<h3 class="section">6.7 Error Handling</h3>

<a name="idna_005fstrerror-1"></a>
<h4 class="subheading">idna_strerror</h4>
<a name="idna_005fstrerror"></a><dl>
<dt><a name="index-idna_005fstrerror"></a>Function: <em>const char *</em> <strong>idna_strerror</strong> <em>(Idna_rc <var>rc</var>)</em></dt>
<dd><p><var>rc</var>: an <code>Idna_rc</code>  return code.
</p>
<p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.
</p>
<p><strong>IDNA_SUCCESS:</strong> Successful operation.  This value is guaranteed to
always be zero, the remaining ones are only guaranteed to hold
non-zero values, for logical comparison purposes.
</p>
<p><strong>IDNA_STRINGPREP_ERROR:</strong> Error during string preparation.
</p>
<p><strong>IDNA_PUNYCODE_ERROR:</strong> Error during punycode operation.
</p>
<p><strong>IDNA_CONTAINS_NON_LDH:</strong> For IDNA_USE_STD3_ASCII_RULES, indicate that
the string contains non-LDH ASCII characters.
</p>
<p><strong>IDNA_CONTAINS_MINUS:</strong> For IDNA_USE_STD3_ASCII_RULES, indicate that
the string contains a leading or trailing hyphen-minus (U+002D).
</p>
<p><strong>IDNA_INVALID_LENGTH:</strong> The final output string is not within the
(inclusive) range 1 to 63 characters.
</p>
<p><strong>IDNA_NO_ACE_PREFIX:</strong> The string does not contain the ACE prefix
(for ToUnicode).
</p>
<p><strong>IDNA_ROUNDTRIP_VERIFY_ERROR:</strong> The ToASCII operation on output
string does not equal the input.
</p>
<p><strong>IDNA_CONTAINS_ACE_PREFIX:</strong> The input contains the ACE prefix (for
ToASCII).
</p>
<p><strong>IDNA_ICONV_ERROR:</strong> Could not convert string in locale encoding.
</p>
<p><strong>IDNA_MALLOC_ERROR:</strong> Could not allocate buffer (this is typically a
fatal error).
</p>
<p><strong>IDNA_DLOPEN_ERROR:</strong> Could not dlopen the libcidn DSO (only used
internally in libc).
</p>
<p>Return value: Returns a pointer to a statically allocated string
containing a description of the error with the return code  <code>rc</code> .
</p></dd></dl>


<hr>
<a name="TLD-Functions"></a>
<div class="header">
<p>
Next: <a href="#PR29-Functions" accesskey="n" rel="next">PR29 Functions</a>, Previous: <a href="#IDNA-Functions" accesskey="p" rel="prev">IDNA Functions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="TLD-Functions-1"></a>
<h2 class="chapter">7 TLD Functions</h2>
<a name="index-TLD-Functions"></a>

<p>Organizations that manage some Top Level Domains (TLDs) have published
tables with characters they accept within the domain.  The reason may
be to reduce complexity that come from using the full Unicode range,
and to protect themselves from future (backwards incompatible) changes
in the IDN or Unicode specifications.  Libidn implement an
infrastructure for defining and checking strings against such tables.
Libidn also ship some tables from TLDs that we have managed to get
permission to use them from.  Because these tables are even less
static than Unicode or StringPrep tables, it is likely that they will
be updated from time to time (even in backwards incompatible ways).
The Libidn interface provide a &ldquo;version&rdquo; field for each TLD table,
which can be compared for equality to guarantee the same operation
over time.
</p>
<p>From a design point of view, you can regard the TLD tables for IDN as
the &ldquo;localization&rdquo; step that come after the &ldquo;internationalization&rdquo;
step provided by the IETF standards.
</p>
<p>The TLD functionality rely on up-to-date tables.  The latest version
of Libidn aim to provide these, but tables with unclear copying
conditions, or generally experimental tables, are not included.  Some
such tables can be found at <a href="https://github.com/gnuthor/tldchk">https://github.com/gnuthor/tldchk</a>.
</p>
<a name="Header-file-tld_002eh"></a>
<h3 class="section">7.1 Header file <code>tld.h</code></h3>

<p>To use the functions explained in this chapter, you need to include
the file <samp>tld.h</samp> using:
</p>
<div class="example">
<pre class="example">#include &lt;tld.h&gt;
</pre></div>


<a name="Core-Functions-3"></a>
<h3 class="section">7.2 Core Functions</h3>

<a name="tld_005fcheck_005f4t-1"></a>
<h4 class="subheading">tld_check_4t</h4>
<a name="tld_005fcheck_005f4t"></a><dl>
<dt><a name="index-tld_005fcheck_005f4t"></a>Function: <em>int</em> <strong>tld_check_4t</strong> <em>(const uint32_t * <var>in</var>, size_t <var>inlen</var>, size_t * <var>errpos</var>, const Tld_table * <var>tld</var>)</em></dt>
<dd><p><var>in</var>: Array of unicode code points to process. Does not need to be
zero terminated.
</p>
<p><var>inlen</var>: Number of unicode code points.
</p>
<p><var>errpos</var>: Position of offending character is returned here.
</p>
<p><var>tld</var>: A <code>Tld_table</code>  data structure representing the restrictions for
which the input should be tested.
</p>
<p>Test each of the code points in  <code>in</code> for whether or not
they are allowed by the data structure in  <code>tld</code> , return
the position of the first character for which this is not
the case in  <code>errpos</code> .
</p>
<p>Return value: Returns the <code>Tld_rc</code>  value <code>TLD_SUCCESS</code>  if all code
points are valid or when  <code>tld</code> is null, <code>TLD_INVALID</code>  if a
character is not allowed, or additional error codes on general
failure conditions.
</p></dd></dl>

<a name="tld_005fcheck_005f4tz-1"></a>
<h4 class="subheading">tld_check_4tz</h4>
<a name="tld_005fcheck_005f4tz"></a><dl>
<dt><a name="index-tld_005fcheck_005f4tz"></a>Function: <em>int</em> <strong>tld_check_4tz</strong> <em>(const uint32_t * <var>in</var>, size_t * <var>errpos</var>, const Tld_table * <var>tld</var>)</em></dt>
<dd><p><var>in</var>: Zero terminated array of unicode code points to process.
</p>
<p><var>errpos</var>: Position of offending character is returned here.
</p>
<p><var>tld</var>: A <code>Tld_table</code>  data structure representing the restrictions for
which the input should be tested.
</p>
<p>Test each of the code points in  <code>in</code> for whether or not
they are allowed by the data structure in  <code>tld</code> , return
the position of the first character for which this is not
the case in  <code>errpos</code> .
</p>
<p>Return value: Returns the <code>Tld_rc</code>  value <code>TLD_SUCCESS</code>  if all code
points are valid or when  <code>tld</code> is null, <code>TLD_INVALID</code>  if a
character is not allowed, or additional error codes on general
failure conditions.
</p></dd></dl>


<a name="Utility-Functions-2"></a>
<h3 class="section">7.3 Utility Functions</h3>

<a name="tld_005fget_005f4-1"></a>
<h4 class="subheading">tld_get_4</h4>
<a name="tld_005fget_005f4"></a><dl>
<dt><a name="index-tld_005fget_005f4"></a>Function: <em>int</em> <strong>tld_get_4</strong> <em>(const uint32_t * <var>in</var>, size_t <var>inlen</var>, char ** <var>out</var>)</em></dt>
<dd><p><var>in</var>: Array of unicode code points to process. Does not need to be
zero terminated.
</p>
<p><var>inlen</var>: Number of unicode code points.
</p>
<p><var>out</var>: Zero terminated ascii result string pointer.
</p>
<p>Isolate the top-level domain of  <code>in</code> and return it as an ASCII
string in  <code>out</code> .
</p>
<p>Return value: Return <code>TLD_SUCCESS</code>  on success, or the corresponding
<code>Tld_rc</code>  error code otherwise.
</p></dd></dl>

<a name="tld_005fget_005f4z-1"></a>
<h4 class="subheading">tld_get_4z</h4>
<a name="tld_005fget_005f4z"></a><dl>
<dt><a name="index-tld_005fget_005f4z"></a>Function: <em>int</em> <strong>tld_get_4z</strong> <em>(const uint32_t * <var>in</var>, char ** <var>out</var>)</em></dt>
<dd><p><var>in</var>: Zero terminated array of unicode code points to process.
</p>
<p><var>out</var>: Zero terminated ascii result string pointer.
</p>
<p>Isolate the top-level domain of  <code>in</code> and return it as an ASCII
string in  <code>out</code> .
</p>
<p>Return value: Return <code>TLD_SUCCESS</code>  on success, or the corresponding
<code>Tld_rc</code>  error code otherwise.
</p></dd></dl>

<a name="tld_005fget_005fz-1"></a>
<h4 class="subheading">tld_get_z</h4>
<a name="tld_005fget_005fz"></a><dl>
<dt><a name="index-tld_005fget_005fz"></a>Function: <em>int</em> <strong>tld_get_z</strong> <em>(const char * <var>in</var>, char ** <var>out</var>)</em></dt>
<dd><p><var>in</var>: Zero terminated character array to process.
</p>
<p><var>out</var>: Zero terminated ascii result string pointer.
</p>
<p>Isolate the top-level domain of  <code>in</code> and return it as an ASCII
string in  <code>out</code> .  The input string  <code>in</code> may be UTF-8, ISO-8859-1 or
any ASCII compatible character encoding.
</p>
<p>Return value: Return <code>TLD_SUCCESS</code>  on success, or the corresponding
<code>Tld_rc</code>  error code otherwise.
</p></dd></dl>

<a name="tld_005fget_005ftable-1"></a>
<h4 class="subheading">tld_get_table</h4>
<a name="tld_005fget_005ftable"></a><dl>
<dt><a name="index-tld_005fget_005ftable"></a>Function: <em>const Tld_table *</em> <strong>tld_get_table</strong> <em>(const char * <var>tld</var>, const Tld_table ** <var>tables</var>)</em></dt>
<dd><p><var>tld</var>: TLD name (e.g. &quot;com&quot;) as zero terminated ASCII byte string.
</p>
<p><var>tables</var>: Zero terminated array of <code>Tld_table</code>  info-structures for
TLDs.
</p>
<p>Get the TLD table for a named TLD by searching through the given
TLD table array.
</p>
<p>Return value: Return structure corresponding to TLD  <code>tld</code> by going
thru  <code>tables</code> , or return <code>NULL</code>  if no such structure is found.
</p></dd></dl>

<a name="tld_005fdefault_005ftable-1"></a>
<h4 class="subheading">tld_default_table</h4>
<a name="tld_005fdefault_005ftable"></a><dl>
<dt><a name="index-tld_005fdefault_005ftable"></a>Function: <em>const Tld_table *</em> <strong>tld_default_table</strong> <em>(const char * <var>tld</var>, const Tld_table ** <var>overrides</var>)</em></dt>
<dd><p><var>tld</var>: TLD name (e.g. &quot;com&quot;) as zero terminated ASCII byte string.
</p>
<p><var>overrides</var>: Additional zero terminated array of <code>Tld_table</code> 
info-structures for TLDs, or <code>NULL</code>  to only use library deault
tables.
</p>
<p>Get the TLD table for a named TLD, using the internal defaults,
possibly overrided by the (optional) supplied tables.
</p>
<p>Return value: Return structure corresponding to TLD  <code>tld_str</code> , first
looking through  <code>overrides</code> then thru built-in list, or <code>NULL</code>  if
no such structure found.
</p></dd></dl>


<a name="High_002dLevel-Wrapper-Functions"></a>
<h3 class="section">7.4 High-Level Wrapper Functions</h3>

<a name="tld_005fcheck_005f4-1"></a>
<h4 class="subheading">tld_check_4</h4>
<a name="tld_005fcheck_005f4"></a><dl>
<dt><a name="index-tld_005fcheck_005f4"></a>Function: <em>int</em> <strong>tld_check_4</strong> <em>(const uint32_t * <var>in</var>, size_t <var>inlen</var>, size_t * <var>errpos</var>, const Tld_table ** <var>overrides</var>)</em></dt>
<dd><p><var>in</var>: Array of unicode code points to process. Does not need to be
zero terminated.
</p>
<p><var>inlen</var>: Number of unicode code points.
</p>
<p><var>errpos</var>: Position of offending character is returned here.
</p>
<p><var>overrides</var>: A <code>Tld_table</code>  array of additional domain restriction
structures that complement and supersede the built-in information.
</p>
<p>Test each of the code points in  <code>in</code> for whether or not they are
allowed by the information in  <code>overrides</code> or by the built-in TLD
restriction data. When data for the same TLD is available both
internally and in  <code>overrides</code> , the information in  <code>overrides</code> takes
precedence. If several entries for a specific TLD are found, the
first one is used.  If  <code>overrides</code> is <code>NULL</code> , only the built-in
information is used.  The position of the first offending character
is returned in  <code>errpos</code> .
</p>
<p>Return value: Returns the <code>Tld_rc</code>  value <code>TLD_SUCCESS</code>  if all code
points are valid or when  <code>tld</code> is null, <code>TLD_INVALID</code>  if a
character is not allowed, or additional error codes on general
failure conditions.
</p></dd></dl>

<a name="tld_005fcheck_005f4z-1"></a>
<h4 class="subheading">tld_check_4z</h4>
<a name="tld_005fcheck_005f4z"></a><dl>
<dt><a name="index-tld_005fcheck_005f4z"></a>Function: <em>int</em> <strong>tld_check_4z</strong> <em>(const uint32_t * <var>in</var>, size_t * <var>errpos</var>, const Tld_table ** <var>overrides</var>)</em></dt>
<dd><p><var>in</var>: Zero-terminated array of unicode code points to process.
</p>
<p><var>errpos</var>: Position of offending character is returned here.
</p>
<p><var>overrides</var>: A <code>Tld_table</code>  array of additional domain restriction
structures that complement and supersede the built-in information.
</p>
<p>Test each of the code points in  <code>in</code> for whether or not they are
allowed by the information in  <code>overrides</code> or by the built-in TLD
restriction data. When data for the same TLD is available both
internally and in  <code>overrides</code> , the information in  <code>overrides</code> takes
precedence. If several entries for a specific TLD are found, the
first one is used.  If  <code>overrides</code> is <code>NULL</code> , only the built-in
information is used.  The position of the first offending character
is returned in  <code>errpos</code> .
</p>
<p>Return value: Returns the <code>Tld_rc</code>  value <code>TLD_SUCCESS</code>  if all code
points are valid or when  <code>tld</code> is null, <code>TLD_INVALID</code>  if a
character is not allowed, or additional error codes on general
failure conditions.
</p></dd></dl>

<a name="tld_005fcheck_005f8z-1"></a>
<h4 class="subheading">tld_check_8z</h4>
<a name="tld_005fcheck_005f8z"></a><dl>
<dt><a name="index-tld_005fcheck_005f8z"></a>Function: <em>int</em> <strong>tld_check_8z</strong> <em>(const char * <var>in</var>, size_t * <var>errpos</var>, const Tld_table ** <var>overrides</var>)</em></dt>
<dd><p><var>in</var>: Zero-terminated UTF8 string to process.
</p>
<p><var>errpos</var>: Position of offending character is returned here.
</p>
<p><var>overrides</var>: A <code>Tld_table</code>  array of additional domain restriction
structures that complement and supersede the built-in information.
</p>
<p>Test each of the characters in  <code>in</code> for whether or not they are
allowed by the information in  <code>overrides</code> or by the built-in TLD
restriction data. When data for the same TLD is available both
internally and in  <code>overrides</code> , the information in  <code>overrides</code> takes
precedence. If several entries for a specific TLD are found, the
first one is used.  If  <code>overrides</code> is <code>NULL</code> , only the built-in
information is used.  The position of the first offending character
is returned in  <code>errpos</code> .  Note that the error position refers to the
decoded character offset rather than the byte position in the
string.
</p>
<p>Return value: Returns the <code>Tld_rc</code>  value <code>TLD_SUCCESS</code>  if all
characters are valid or when  <code>tld</code> is null, <code>TLD_INVALID</code>  if a
character is not allowed, or additional error codes on general
failure conditions.
</p></dd></dl>

<a name="tld_005fcheck_005flz-1"></a>
<h4 class="subheading">tld_check_lz</h4>
<a name="tld_005fcheck_005flz"></a><dl>
<dt><a name="index-tld_005fcheck_005flz"></a>Function: <em>int</em> <strong>tld_check_lz</strong> <em>(const char * <var>in</var>, size_t * <var>errpos</var>, const Tld_table ** <var>overrides</var>)</em></dt>
<dd><p><var>in</var>: Zero-terminated string in the current locales encoding to process.
</p>
<p><var>errpos</var>: Position of offending character is returned here.
</p>
<p><var>overrides</var>: A <code>Tld_table</code>  array of additional domain restriction
structures that complement and supersede the built-in information.
</p>
<p>Test each of the characters in  <code>in</code> for whether or not they are
allowed by the information in  <code>overrides</code> or by the built-in TLD
restriction data. When data for the same TLD is available both
internally and in  <code>overrides</code> , the information in  <code>overrides</code> takes
precedence. If several entries for a specific TLD are found, the
first one is used.  If  <code>overrides</code> is <code>NULL</code> , only the built-in
information is used.  The position of the first offending character
is returned in  <code>errpos</code> .  Note that the error position refers to the
decoded character offset rather than the byte position in the
string.
</p>
<p>Return value: Returns the <code>Tld_rc</code>  value <code>TLD_SUCCESS</code>  if all
characters are valid or when  <code>tld</code> is null, <code>TLD_INVALID</code>  if a
character is not allowed, or additional error codes on general
failure conditions.
</p></dd></dl>


<a name="Error-Handling-3"></a>
<h3 class="section">7.5 Error Handling</h3>

<a name="tld_005fstrerror-1"></a>
<h4 class="subheading">tld_strerror</h4>
<a name="tld_005fstrerror"></a><dl>
<dt><a name="index-tld_005fstrerror"></a>Function: <em>const char *</em> <strong>tld_strerror</strong> <em>(Tld_rc <var>rc</var>)</em></dt>
<dd><p><var>rc</var>: tld return code
</p>
<p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.
</p>
<p><strong>TLD_SUCCESS:</strong> Successful operation.  This value is guaranteed to
always be zero, the remaining ones are only guaranteed to hold
non-zero values, for logical comparison purposes.
</p>
<p><strong>TLD_INVALID:</strong> Invalid character found.
</p>
<p><strong>TLD_NODATA:</strong> No input data was provided.
</p>
<p><strong>TLD_MALLOC_ERROR:</strong> Error during memory allocation.
</p>
<p><strong>TLD_ICONV_ERROR:</strong> Error during iconv string conversion.
</p>
<p><strong>TLD_NO_TLD:</strong> No top-level domain found in domain string.
</p>
<p>Return value: Returns a pointer to a statically allocated string
containing a description of the error with the return code  <code>rc</code> .
</p></dd></dl>


<hr>
<a name="PR29-Functions"></a>
<div class="header">
<p>
Next: <a href="#Examples" accesskey="n" rel="next">Examples</a>, Previous: <a href="#TLD-Functions" accesskey="p" rel="prev">TLD Functions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="PR29-Functions-1"></a>
<h2 class="chapter">8 PR29 Functions</h2>
<a name="index-PR29-Functions"></a>

<p>A deficiency in the specification of Unicode Normalization Forms has
been found.  The consequence is that some strings can be normalized
into different strings by different implementations.  In other words,
two different implementations may return different output for the same
input (because the interpretation of the specification is
ambiguous). Further, an implementation invoked again on the one of the
output strings may return a different string (because one of the
interpretation of the ambiguous specification make normalization
non-idempotent).  Fortunately, only a select few character sequence
exhibit this problem, and none of them are expected to occur in
natural languages (due to different linguistic uses of the involved
characters).
</p>
<p>A full discussion of the problem may be found at:
</p>
<p><a href="http://www.unicode.org/review/pr-29.html">http://www.unicode.org/review/pr-29.html</a>
</p>
<p>The PR29 functions below allow you to detect the problem sequence.  So
when would you want to use these functions?  For most applications,
such as those using Nameprep for IDN, this is likely only to be an
interoperability problem.  Thus, you may not want to care about it, as
the character sequences will rarely occur naturally.  However, if you
are using a profile, such as SASLPrep, to process authentication
tokens; authorization tokens; or passwords, there is a real danger
that attackers may try to use the peculiarities in these strings to
attack parts of your system.  As only a small number of strings, and
no naturally occurring strings, exhibit this problem, the conservative
approach of rejecting the strings is recommended.  If this approach is
not used, you should instead verify that all parts of your system,
that process the tokens and passwords, use a NFKC implementation that
produce the same output for the same input.
</p>
<p>Technically inclined readers may be interested in knowing more about
the implementation aspects of the PR29 flaw. See <a href="#PR29-discussion">PR29 discussion</a>.
</p>
<a name="Header-file-pr29_002eh"></a>
<h3 class="section">8.1 Header file <code>pr29.h</code></h3>

<p>To use the functions explained in this chapter, you need to include
the file <samp>pr29.h</samp> using:
</p>
<div class="example">
<pre class="example">#include &lt;pr29.h&gt;
</pre></div>

<a name="Core-Functions-4"></a>
<h3 class="section">8.2 Core Functions</h3>

<a name="pr29_005f4-1"></a>
<h4 class="subheading">pr29_4</h4>
<a name="pr29_005f4"></a><dl>
<dt><a name="index-pr29_005f4"></a>Function: <em>int</em> <strong>pr29_4</strong> <em>(const uint32_t * <var>in</var>, size_t <var>len</var>)</em></dt>
<dd><p><var>in</var>: input array with unicode code points.
</p>
<p><var>len</var>: length of input array with unicode code points.
</p>
<p>Check the input to see if it may be normalized into different
strings by different NFKC implementations, due to an anomaly in the
NFKC specifications.
</p>
<p>Return value: Returns the <code>Pr29_rc</code>  value <code>PR29_SUCCESS</code>  on success,
and <code>PR29_PROBLEM</code>  if the input sequence is a &quot;problem sequence&quot;
(i.e., may be normalized into different strings by different
implementations).
</p></dd></dl>


<a name="Utility-Functions-3"></a>
<h3 class="section">8.3 Utility Functions</h3>

<a name="pr29_005f4z-1"></a>
<h4 class="subheading">pr29_4z</h4>
<a name="pr29_005f4z"></a><dl>
<dt><a name="index-pr29_005f4z"></a>Function: <em>int</em> <strong>pr29_4z</strong> <em>(const uint32_t * <var>in</var>)</em></dt>
<dd><p><var>in</var>: zero terminated array of Unicode code points.
</p>
<p>Check the input to see if it may be normalized into different
strings by different NFKC implementations, due to an anomaly in the
NFKC specifications.
</p>
<p>Return value: Returns the <code>Pr29_rc</code>  value <code>PR29_SUCCESS</code>  on success,
and <code>PR29_PROBLEM</code>  if the input sequence is a &quot;problem sequence&quot;
(i.e., may be normalized into different strings by different
implementations).
</p></dd></dl>

<a name="pr29_005f8z-1"></a>
<h4 class="subheading">pr29_8z</h4>
<a name="pr29_005f8z"></a><dl>
<dt><a name="index-pr29_005f8z"></a>Function: <em>int</em> <strong>pr29_8z</strong> <em>(const char * <var>in</var>)</em></dt>
<dd><p><var>in</var>: zero terminated input UTF-8 string.
</p>
<p>Check the input to see if it may be normalized into different
strings by different NFKC implementations, due to an anomaly in the
NFKC specifications.
</p>
<p>Return value: Returns the <code>Pr29_rc</code>  value <code>PR29_SUCCESS</code>  on success,
and <code>PR29_PROBLEM</code>  if the input sequence is a &quot;problem sequence&quot;
(i.e., may be normalized into different strings by different
implementations), or <code>PR29_STRINGPREP_ERROR</code>  if there was a
problem converting the string from UTF-8 to UCS-4.
</p></dd></dl>


<a name="Error-Handling-4"></a>
<h3 class="section">8.4 Error Handling</h3>

<a name="pr29_005fstrerror-1"></a>
<h4 class="subheading">pr29_strerror</h4>
<a name="pr29_005fstrerror"></a><dl>
<dt><a name="index-pr29_005fstrerror"></a>Function: <em>const char *</em> <strong>pr29_strerror</strong> <em>(Pr29_rc <var>rc</var>)</em></dt>
<dd><p><var>rc</var>: an <code>Pr29_rc</code>  return code.
</p>
<p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.
</p>
<p><strong>PR29_SUCCESS:</strong> Successful operation.  This value is guaranteed to
always be zero, the remaining ones are only guaranteed to hold
non-zero values, for logical comparison purposes.
</p>
<p><strong>PR29_PROBLEM:</strong> A problem sequence was encountered.
</p>
<p><strong>PR29_STRINGPREP_ERROR:</strong> The character set conversion failed (only
for <code>pr29_8z()</code> ).
</p>
<p>Return value: Returns a pointer to a statically allocated string
containing a description of the error with the return code  <code>rc</code> .
</p></dd></dl>


<hr>
<a name="Examples"></a>
<div class="header">
<p>
Next: <a href="#Invoking-idn" accesskey="n" rel="next">Invoking idn</a>, Previous: <a href="#PR29-Functions" accesskey="p" rel="prev">PR29 Functions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Examples-1"></a>
<h2 class="chapter">9 Examples</h2>
<a name="index-Examples"></a>

<p>This chapter contains example code which illustrate how &lsquo;Libidn&rsquo; can
be used when writing your own application.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Example-1" accesskey="1">Example 1</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Example using stringprep.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Example-2" accesskey="2">Example 2</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Example using punycode.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Example-3" accesskey="3">Example 3</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Example using IDNA ToASCII.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Example-4" accesskey="4">Example 4</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Example using IDNA ToUnicode.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Example-5" accesskey="5">Example 5</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Example using TLD checking.
</td></tr>
</table>

<hr>
<a name="Example-1"></a>
<div class="header">
<p>
Next: <a href="#Example-2" accesskey="n" rel="next">Example 2</a>, Up: <a href="#Examples" accesskey="u" rel="up">Examples</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Example-1-1"></a>
<h3 class="section">9.1 Example 1</h3>

<p>This example demonstrates how the stringprep functions are used.
</p>
<pre class="verbatim">/* example.c --- Example code showing how to use stringprep().
 * Copyright (C) 2002-2016 Simon Josefsson
 *
 * This file is part of GNU Libidn.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 *
 */

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;locale.h&gt;		/* setlocale() */
#include &lt;stringprep.h&gt;

/*
 * Compiling using libtool and pkg-config is recommended:
 *
 * $ libtool cc -o example example.c `pkg-config --cflags --libs libidn`
 * $ ./example
 * Input string encoded as `ISO-8859-1': ª
 * Before locale2utf8 (length 2): aa 0a
 * Before stringprep (length 3): c2 aa 0a
 * After stringprep (length 2): 61 0a
 * $
 *
 */

int
main (void)
{
  char buf[BUFSIZ];
  char *p;
  int rc;
  size_t i;

  setlocale (LC_ALL, &quot;&quot;);

  printf (&quot;Input string encoded as `%s': &quot;, stringprep_locale_charset ());
  fflush (stdout);
  if (!fgets (buf, BUFSIZ, stdin))
    perror (&quot;fgets&quot;);
  buf[strlen (buf) - 1] = '\0';

  printf (&quot;Before locale2utf8 (length %ld): &quot;, (long int) strlen (buf));
  for (i = 0; i &lt; strlen (buf); i++)
    printf (&quot;%02x &quot;, (unsigned) buf[i] &amp; 0xFF);
  printf (&quot;\n&quot;);

  p = stringprep_locale_to_utf8 (buf);
  if (p)
    {
      strcpy (buf, p);
      free (p);
    }
  else
    printf (&quot;Could not convert string to UTF-8, continuing anyway...\n&quot;);

  printf (&quot;Before stringprep (length %ld): &quot;, (long int) strlen (buf));
  for (i = 0; i &lt; strlen (buf); i++)
    printf (&quot;%02x &quot;, (unsigned) buf[i] &amp; 0xFF);
  printf (&quot;\n&quot;);

  rc = stringprep (buf, BUFSIZ, 0, stringprep_nameprep);
  if (rc != STRINGPREP_OK)
    printf (&quot;Stringprep failed (%d): %s\n&quot;, rc, stringprep_strerror (rc));
  else
    {
      printf (&quot;After stringprep (length %ld): &quot;, (long int) strlen (buf));
      for (i = 0; i &lt; strlen (buf); i++)
	printf (&quot;%02x &quot;, (unsigned) buf[i] &amp; 0xFF);
      printf (&quot;\n&quot;);
    }

  return 0;
}
</pre>
<hr>
<a name="Example-2"></a>
<div class="header">
<p>
Next: <a href="#Example-3" accesskey="n" rel="next">Example 3</a>, Previous: <a href="#Example-1" accesskey="p" rel="prev">Example 1</a>, Up: <a href="#Examples" accesskey="u" rel="up">Examples</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Example-2-1"></a>
<h3 class="section">9.2 Example 2</h3>

<p>This example demonstrates how the punycode functions are used.
</p>
<pre class="verbatim">/* example2.c --- Example code showing how to use punycode.
 * Copyright (C) 2002-2016 Simon Josefsson
 * Copyright (C) 2002  Adam M. Costello
 *
 * This file is part of GNU Libidn.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 *
 */

#include &lt;locale.h&gt;		/* setlocale() */

/*
 * This file is derived from RFC 3492 written by Adam M. Costello.
 *
 * Disclaimer and license: Regarding this entire document or any
 * portion of it (including the pseudocode and C code), the author
 * makes no guarantees and is not responsible for any damage resulting
 * from its use.  The author grants irrevocable permission to anyone
 * to use, modify, and distribute it in any way that does not diminish
 * the rights of anyone else to use, modify, and distribute it,
 * provided that redistributed derivative works do not contain
 * misleading author or version information.  Derivative works need
 * not be licensed under similar terms.
 *
 */

#include &lt;assert.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

#include &lt;punycode.h&gt;

/* For testing, we'll just set some compile-time limits rather than */
/* use malloc(), and set a compile-time option rather than using a  */
/* command-line option.                                             */

enum
{
  unicode_max_length = 256,
  ace_max_length = 256
};

static void
usage (char **argv)
{
  fprintf (stderr,
	   &quot;\n&quot;
	   &quot;%s -e reads code points and writes a Punycode string.\n&quot;
	   &quot;%s -d reads a Punycode string and writes code points.\n&quot;
	   &quot;\n&quot;
	   &quot;Input and output are plain text in the native character set.\n&quot;
	   &quot;Code points are in the form u+hex separated by whitespace.\n&quot;
	   &quot;Although the specification allows Punycode strings to contain\n&quot;
	   &quot;any characters from the ASCII repertoire, this test code\n&quot;
	   &quot;supports only the printable characters, and needs the Punycode\n&quot;
	   &quot;string to be followed by a newline.\n&quot;
	   &quot;The case of the u in u+hex is the force-to-uppercase flag.\n&quot;,
	   argv[0], argv[0]);
  exit (EXIT_FAILURE);
}

static void
fail (const char *msg)
{
  fputs (msg, stderr);
  exit (EXIT_FAILURE);
}

static const char too_big[] =
  &quot;input or output is too large, recompile with larger limits\n&quot;;
static const char invalid_input[] = &quot;invalid input\n&quot;;
static const char overflow[] = &quot;arithmetic overflow\n&quot;;
static const char io_error[] = &quot;I/O error\n&quot;;

/* The following string is used to convert printable */
/* characters between ASCII and the native charset:  */

static const char print_ascii[] = &quot;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n&quot; &quot;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n&quot; &quot; !\&quot;#$%&amp;'()*+,-./&quot; &quot;0123456789:;&lt;=&gt;?&quot; &quot;\0x40&quot;	/* at sign */
  &quot;ABCDEFGHIJKLMNO&quot;
  &quot;PQRSTUVWXYZ[\\]^_&quot; &quot;`abcdefghijklmno&quot; &quot;pqrstuvwxyz{|}~\n&quot;;

int
main (int argc, char **argv)
{
  enum punycode_status status;
  int r;
  size_t input_length, output_length, j;
  unsigned char case_flags[unicode_max_length];

  setlocale (LC_ALL, &quot;&quot;);

  if (argc != 2)
    usage (argv);
  if (argv[1][0] != '-')
    usage (argv);
  if (argv[1][2] != 0)
    usage (argv);

  if (argv[1][1] == 'e')
    {
      uint32_t input[unicode_max_length];
      unsigned long codept;
      char output[ace_max_length + 1], uplus[3];
      int c;

      /* Read the input code points: */

      input_length = 0;

      for (;;)
	{
	  r = scanf (&quot;%2s%lx&quot;, uplus, &amp;codept);
	  if (ferror (stdin))
	    fail (io_error);
	  if (r == EOF || r == 0)
	    break;

	  if (r != 2 || uplus[1] != '+' || codept &gt; (uint32_t) - 1)
	    {
	      fail (invalid_input);
	    }

	  if (input_length == unicode_max_length)
	    fail (too_big);

	  if (uplus[0] == 'u')
	    case_flags[input_length] = 0;
	  else if (uplus[0] == 'U')
	    case_flags[input_length] = 1;
	  else
	    fail (invalid_input);

	  input[input_length++] = codept;
	}

      /* Encode: */

      output_length = ace_max_length;
      status = punycode_encode (input_length, input, case_flags,
				&amp;output_length, output);
      if (status == punycode_bad_input)
	fail (invalid_input);
      if (status == punycode_big_output)
	fail (too_big);
      if (status == punycode_overflow)
	fail (overflow);
      assert (status == punycode_success);

      /* Convert to native charset and output: */

      for (j = 0; j &lt; output_length; ++j)
	{
	  c = output[j];
	  assert (c &gt;= 0 &amp;&amp; c &lt;= 127);
	  if (print_ascii[c] == 0)
	    fail (invalid_input);
	  output[j] = print_ascii[c];
	}

      output[j] = 0;
      r = puts (output);
      if (r == EOF)
	fail (io_error);
      return EXIT_SUCCESS;
    }

  if (argv[1][1] == 'd')
    {
      char input[ace_max_length + 2], *p, *pp;
      uint32_t output[unicode_max_length];

      /* Read the Punycode input string and convert to ASCII: */

      if (!fgets (input, ace_max_length + 2, stdin))
	fail (io_error);
      if (ferror (stdin))
	fail (io_error);
      if (feof (stdin))
	fail (invalid_input);
      input_length = strlen (input) - 1;
      if (input[input_length] != '\n')
	fail (too_big);
      input[input_length] = 0;

      for (p = input; *p != 0; ++p)
	{
	  pp = strchr (print_ascii, *p);
	  if (pp == 0)
	    fail (invalid_input);
	  *p = pp - print_ascii;
	}

      /* Decode: */

      output_length = unicode_max_length;
      status = punycode_decode (input_length, input, &amp;output_length,
				output, case_flags);
      if (status == punycode_bad_input)
	fail (invalid_input);
      if (status == punycode_big_output)
	fail (too_big);
      if (status == punycode_overflow)
	fail (overflow);
      assert (status == punycode_success);

      /* Output the result: */

      for (j = 0; j &lt; output_length; ++j)
	{
	  r = printf (&quot;%s+%04lX\n&quot;,
		      case_flags[j] ? &quot;U&quot; : &quot;u&quot;, (unsigned long) output[j]);
	  if (r &lt; 0)
	    fail (io_error);
	}

      return EXIT_SUCCESS;
    }

  usage (argv);
  return EXIT_SUCCESS;		/* not reached, but quiets compiler warning */
}
</pre>
<hr>
<a name="Example-3"></a>
<div class="header">
<p>
Next: <a href="#Example-4" accesskey="n" rel="next">Example 4</a>, Previous: <a href="#Example-2" accesskey="p" rel="prev">Example 2</a>, Up: <a href="#Examples" accesskey="u" rel="up">Examples</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Example-3-1"></a>
<h3 class="section">9.3 Example 3</h3>

<p>This example demonstrates how the library is used to convert
internationalized domain names into ASCII compatible names.
</p>
<pre class="verbatim">/* example3.c --- Example ToASCII() code showing how to use Libidn.
 * Copyright (C) 2002-2016 Simon Josefsson
 *
 * This file is part of GNU Libidn.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 *
 */

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;locale.h&gt;		/* setlocale() */
#include &lt;stringprep.h&gt;		/* stringprep_locale_charset() */
#include &lt;idna.h&gt;		/* idna_to_ascii_lz() */

/*
 * Compiling using libtool and pkg-config is recommended:
 *
 * $ libtool cc -o example3 example3.c `pkg-config --cflags --libs libidn`
 * $ ./example3
 * Input domain encoded as `ISO-8859-1': www.räksmörgåsª.example
 * Read string (length 23): 77 77 77 2e 72 e4 6b 73 6d f6 72 67 e5 73 aa 2e 65 78 61 6d 70 6c 65
 * ACE label (length 33): 'www.xn--rksmrgsa-0zap8p.example'
 * 77 77 77 2e 78 6e 2d 2d 72 6b 73 6d 72 67 73 61 2d 30 7a 61 70 38 70 2e 65 78 61 6d 70 6c 65
 * $
 *
 */

int
main (void)
{
  char buf[BUFSIZ];
  char *p;
  int rc;
  size_t i;

  setlocale (LC_ALL, &quot;&quot;);

  printf (&quot;Input domain encoded as `%s': &quot;, stringprep_locale_charset ());
  fflush (stdout);
  if (!fgets (buf, BUFSIZ, stdin))
    perror (&quot;fgets&quot;);
  buf[strlen (buf) - 1] = '\0';

  printf (&quot;Read string (length %ld): &quot;, (long int) strlen (buf));
  for (i = 0; i &lt; strlen (buf); i++)
    printf (&quot;%02x &quot;, (unsigned) buf[i] &amp; 0xFF);
  printf (&quot;\n&quot;);

  rc = idna_to_ascii_lz (buf, &amp;p, 0);
  if (rc != IDNA_SUCCESS)
    {
      printf (&quot;ToASCII() failed (%d): %s\n&quot;, rc, idna_strerror (rc));
      return EXIT_FAILURE;
    }

  printf (&quot;ACE label (length %ld): '%s'\n&quot;, (long int) strlen (p), p);
  for (i = 0; i &lt; strlen (p); i++)
    printf (&quot;%02x &quot;, (unsigned) p[i] &amp; 0xFF);
  printf (&quot;\n&quot;);

  free (p);

  return 0;
}
</pre>
<hr>
<a name="Example-4"></a>
<div class="header">
<p>
Next: <a href="#Example-5" accesskey="n" rel="next">Example 5</a>, Previous: <a href="#Example-3" accesskey="p" rel="prev">Example 3</a>, Up: <a href="#Examples" accesskey="u" rel="up">Examples</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Example-4-1"></a>
<h3 class="section">9.4 Example 4</h3>

<p>This example demonstrates how the library is used to convert ASCII
compatible names to internationalized domain names.
</p>
<pre class="verbatim">/* example4.c --- Example ToUnicode() code showing how to use Libidn.
 * Copyright (C) 2002-2016 Simon Josefsson
 *
 * This file is part of GNU Libidn.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 *
 */

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;locale.h&gt;		/* setlocale() */
#include &lt;stringprep.h&gt;		/* stringprep_locale_charset() */
#include &lt;idna.h&gt;		/* idna_to_unicode_lzlz() */

/*
 * Compiling using libtool and pkg-config is recommended:
 *
 * $ libtool cc -o example4 example4.c `pkg-config --cflags --libs libidn`
 * $ ./example4
 * Input domain encoded as `ISO-8859-1': www.xn--rksmrgsa-0zap8p.example
 * Read string (length 33): 77 77 77 2e 78 6e 2d 2d 72 6b 73 6d 72 67 73 61 2d 30 7a 61 70 38 70 2e 65 78 61 6d 70 6c 65
 * ACE label (length 23): 'www.räksmörgåsa.example'
 * 77 77 77 2e 72 e4 6b 73 6d f6 72 67 e5 73 61 2e 65 78 61 6d 70 6c 65
 * $
 *
 */

int
main (void)
{
  char buf[BUFSIZ];
  char *p;
  int rc;
  size_t i;

  setlocale (LC_ALL, &quot;&quot;);

  printf (&quot;Input domain encoded as `%s': &quot;, stringprep_locale_charset ());
  fflush (stdout);
  if (!fgets (buf, BUFSIZ, stdin))
    perror (&quot;fgets&quot;);
  buf[strlen (buf) - 1] = '\0';

  printf (&quot;Read string (length %ld): &quot;, (long int) strlen (buf));
  for (i = 0; i &lt; strlen (buf); i++)
    printf (&quot;%02x &quot;, (unsigned) buf[i] &amp; 0xFF);
  printf (&quot;\n&quot;);

  rc = idna_to_unicode_lzlz (buf, &amp;p, 0);
  if (rc != IDNA_SUCCESS)
    {
      printf (&quot;ToUnicode() failed (%d): %s\n&quot;, rc, idna_strerror (rc));
      return EXIT_FAILURE;
    }

  printf (&quot;ACE label (length %ld): '%s'\n&quot;, (long int) strlen (p), p);
  for (i = 0; i &lt; strlen (p); i++)
    printf (&quot;%02x &quot;, (unsigned) p[i] &amp; 0xFF);
  printf (&quot;\n&quot;);

  free (p);

  return 0;
}
</pre>
<hr>
<a name="Example-5"></a>
<div class="header">
<p>
Previous: <a href="#Example-4" accesskey="p" rel="prev">Example 4</a>, Up: <a href="#Examples" accesskey="u" rel="up">Examples</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Example-5-1"></a>
<h3 class="section">9.5 Example 5</h3>

<p>This example demonstrates how the library is used to check a string
for invalid characters within a specific TLD.
</p>
<pre class="verbatim">/* example5.c --- Example TLD checking.
 * Copyright (C) 2004-2016 Simon Josefsson
 *
 * This file is part of GNU Libidn.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 *
 */

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

/* Get stringprep_locale_charset, etc. */
#include &lt;stringprep.h&gt;

/* Get idna_to_ascii_8z, etc. */
#include &lt;idna.h&gt;

/* Get tld_check_4z. */
#include &lt;tld.h&gt;

/*
 * Compiling using libtool and pkg-config is recommended:
 *
 * $ libtool cc -o example5 example5.c `pkg-config --cflags --libs libidn`
 * $ ./example5
 * Input domain encoded as `UTF-8': fooß.no
 * Read string (length 8): 66 6f 6f c3 9f 2e 6e 6f
 * ToASCII string (length 8): fooss.no
 * ToUnicode string: U+0066 U+006f U+006f U+0073 U+0073 U+002e U+006e U+006f
 * Domain accepted by TLD check
 *
 * $ ./example5
 * Input domain encoded as `UTF-8': gr€€n.no
 * Read string (length 12): 67 72 e2 82 ac e2 82 ac 6e 2e 6e 6f
 * ToASCII string (length 16): xn--grn-l50aa.no
 * ToUnicode string: U+0067 U+0072 U+20ac U+20ac U+006e U+002e U+006e U+006f
 * Domain rejected by TLD check, Unicode position 2
 *
 */

int
main (void)
{
  char buf[BUFSIZ];
  char *p;
  uint32_t *r;
  int rc;
  size_t errpos, i;

  printf (&quot;Input domain encoded as `%s': &quot;, stringprep_locale_charset ());
  fflush (stdout);
  if (!fgets (buf, BUFSIZ, stdin))
    perror (&quot;fgets&quot;);
  buf[strlen (buf) - 1] = '\0';

  printf (&quot;Read string (length %ld): &quot;, (long int) strlen (buf));
  for (i = 0; i &lt; strlen (buf); i++)
    printf (&quot;%02x &quot;, (unsigned) buf[i] &amp; 0xFF);
  printf (&quot;\n&quot;);

  p = stringprep_locale_to_utf8 (buf);
  if (p)
    {
      strcpy (buf, p);
      free (p);
    }
  else
    printf (&quot;Could not convert string to UTF-8, continuing anyway...\n&quot;);

  rc = idna_to_ascii_8z (buf, &amp;p, 0);
  if (rc != IDNA_SUCCESS)
    {
      printf (&quot;idna_to_ascii_8z failed (%d): %s\n&quot;, rc, idna_strerror (rc));
      return 2;
    }

  printf (&quot;ToASCII string (length %ld): %s\n&quot;, (long int) strlen (p), p);

  rc = idna_to_unicode_8z4z (p, &amp;r, 0);
  free (p);
  if (rc != IDNA_SUCCESS)
    {
      printf (&quot;idna_to_unicode_8z4z failed (%d): %s\n&quot;,
	      rc, idna_strerror (rc));
      return 2;
    }

  printf (&quot;ToUnicode string: &quot;);
  for (i = 0; r[i]; i++)
    printf (&quot;U+%04x &quot;, r[i]);
  printf (&quot;\n&quot;);

  rc = tld_check_4z (r, &amp;errpos, NULL);
  free (r);
  if (rc == TLD_INVALID)
    {
      printf (&quot;Domain rejected by TLD check, Unicode position %ld\n&quot;, (long int) errpos);
      return 1;
    }
  else if (rc != TLD_SUCCESS)
    {
      printf (&quot;tld_check_4z() failed (%d): %s\n&quot;, rc, tld_strerror (rc));
      return 2;
    }

  printf (&quot;Domain accepted by TLD check\n&quot;);

  return 0;
}
</pre>
<hr>
<a name="Invoking-idn"></a>
<div class="header">
<p>
Next: <a href="#Emacs-API" accesskey="n" rel="next">Emacs API</a>, Previous: <a href="#Examples" accesskey="p" rel="prev">Examples</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-idn-1"></a>
<h2 class="chapter">10 Invoking idn</h2>

<a name="index-idn"></a>
<a name="index-invoking-idn"></a>
<a name="index-command-line"></a>

<a name="Name"></a>
<h3 class="section">10.1 Name</h3>

<p>GNU Libidn (idn) &ndash; Internationalized Domain Names command line tool
</p>
<a name="Description"></a>
<h3 class="section">10.2 Description</h3>
<p><code>idn</code> allows internationalized string preparation
(&lsquo;<samp>stringprep</samp>&rsquo;), encoding and decoding of punycode data, and IDNA
ToASCII/ToUnicode operations to be performed on the command line.
</p>
<p>If strings are specified on the command line, they are used as input
and the computed output is printed to standard output <code>stdout</code>.
If no strings are specified on the command line, the program read
data, line by line, from the standard input <code>stdin</code>, and print
the computed output to standard output.  What processing is performed
(e.g., ToASCII, or Punycode encode) is indicated by options.  If any
errors are encountered, the execution of the applications is aborted.
</p>
<p>All strings are expected to be encoded in the preferred charset used
by your locale.  Use <code>--debug</code> to find out what this charset is.
You can override the charset used by setting environment variable
<code>CHARSET</code>.
</p>
<p>To process a string that starts with <code>-</code>, for example
<code>-foo</code>, use <code>--</code> to signal the end of parameters, as in
<code>idn --quiet -a -- -foo</code>.
</p>
<a name="Options"></a>
<h3 class="section">10.3 Options</h3>
<p><code>idn</code> recognizes these commands:
</p>
<pre class="verbatim">  -h, --help               Print help and exit

  -V, --version            Print version and exit

  -s, --stringprep         Prepare string according to nameprep profile

  -d, --punycode-decode    Decode Punycode

  -e, --punycode-encode    Encode Punycode

  -a, --idna-to-ascii      Convert to ACE according to IDNA (default mode)

  -u, --idna-to-unicode    Convert from ACE according to IDNA

      --allow-unassigned   Toggle IDNA AllowUnassigned flag (default off)

      --usestd3asciirules  Toggle IDNA UseSTD3ASCIIRules flag (default off)

      --no-tld             Don't check string for TLD specific rules
                             Only for --idna-to-ascii and --idna-to-unicode

  -n, --nfkc               Normalize string according to Unicode v3.2 NFKC

  -p, --profile=STRING     Use specified stringprep profile instead
                             Valid stringprep profiles: `Nameprep',
                             `iSCSI', `Nodeprep', `Resourceprep',
                             `trace', `SASLprep'

      --debug              Print debugging information

      --quiet              Silent operation
</pre>
<a name="Environment-Variables"></a>
<h3 class="section">10.4 Environment Variables</h3>

<p>The <var>CHARSET</var> environment variable can be used to override what
character set to be used for decoding incoming data (i.e., on the
command line or on the standard input stream), and to encode data to
the standard output.  If your system is set up correctly, however, the
application will guess which character set is used automatically.
Example usage:
</p>
<div class="example">
<pre class="example">$ CHARSET=ISO-8859-1 idn --punycode-encode
...
</pre></div>

<a name="Examples-2"></a>
<h3 class="section">10.5 Examples</h3>

<p>Standard usage, reading input from standard input:
</p>
<div class="example">
<pre class="example">jas@latte:~$ idn
libidn 0.3.5
Copyright 2002, 2003 Simon Josefsson.
GNU Libidn comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Libidn under the terms of
the GNU Lesser General Public License.  For more information
about these matters, see the file named COPYING.LIB.
Type each input string on a line by itself, terminated by a newline character.
r&auml;ksm&ouml;rg&aring;s.se
xn--rksmrgs-5wao1o.se
jas@latte:~$
</pre></div>

<p>Reading input from command line, and disable printing copyright and
license information:
</p>
<div class="example">
<pre class="example">jas@latte:~$ idn --quiet r&auml;ksm&ouml;rg&aring;s.se bl&aring;b&aelig;rgr&oslash;d.no
xn--rksmrgs-5wao1o.se
xn--blbrgrd-fxak7p.no
jas@latte:~$
</pre></div>

<p>Accessing a specific StringPrep profile directly:
</p>
<div class="example">
<pre class="example">jas@latte:~$ idn --quiet --profile=SASLprep --stringprep te&szlig;t&ordf;
te&szlig;ta
jas@latte:~$
</pre></div>

<a name="Troubleshooting"></a>
<h3 class="section">10.6 Troubleshooting</h3>

<p>Getting character data encoded right, and making sure Libidn use the
same encoding, can be difficult.  The reason for this is that most
systems encode character data in more than one character encoding,
i.e., using <code>UTF-8</code> together with <code>ISO-8859-1</code> or
<code>ISO-2022-JP</code>.  This problem is likely to continue to exist until
only one character encoding come out as the evolutionary winner, or
(more likely, at least to some extents) forever.
</p>
<p>The first step to troubleshooting character encoding problems with
Libidn is to use the &lsquo;<samp>--debug</samp>&rsquo; parameter to find out which
character set encoding &lsquo;<samp>idn</samp>&rsquo; believe your locale uses.
</p>
<div class="example">
<pre class="example">jas@latte:~$ idn --debug --quiet &quot;&quot;
system locale uses charset `UTF-8'.

jas@latte:~$
</pre></div>

<p>If it prints <code>ANSI_X3.4-1968</code> (i.e., <code>US-ASCII</code>), this
indicate you have not configured your locale properly.  To configure
the locale, you can, for example, use &lsquo;<samp>LANG=sv_SE.UTF-8; export
LANG</samp>&rsquo; at a <code>/bin/sh</code> prompt, to set up your locale for a Swedish
environment using <code>UTF-8</code> as the encoding.
</p>
<p>Sometimes &lsquo;<samp>idn</samp>&rsquo; appear to be unable to translate from your system
locale into <code>UTF-8</code> (which is used internally), and you get an
error like the following:
</p>
<div class="example">
<pre class="example">jas@latte:~$ idn --quiet foo
idn: could not convert from ISO-8859-1 to UTF-8.
jas@latte:~$
</pre></div>

<p>The simplest explanation is that you haven&rsquo;t installed the
&lsquo;<samp>iconv</samp>&rsquo; conversion tools.  You can find it as a standalone
library in GNU Libiconv
(<a href="http://www.gnu.org/software/libiconv/">http://www.gnu.org/software/libiconv/</a>).  On many GNU/Linux
systems, this library is part of the system, but you may have to
install additional packages (e.g., &lsquo;<samp>glibc-locale</samp>&rsquo; for Debian) to
be able to use it.
</p>
<p>Another explanation is that the error is correct and you are feeding
&lsquo;<samp>idn</samp>&rsquo; invalid data.  This can happen inadvertently if you are not
careful with the character set encoding you use.  For example, if your
shell run in a <code>ISO-8859-1</code> environment, and you invoke
&lsquo;<samp>idn</samp>&rsquo; with the &lsquo;<samp>CHARSET</samp>&rsquo; environment variable as follows,
you will feed it <code>ISO-8859-1</code> characters but force it to believe
they are <code>UTF-8</code>.  Naturally this will lead to an error, unless
the byte sequences happen to be valid <code>UTF-8</code>.  Note that even if
you don&rsquo;t get an error, the output may be incorrect in this situation,
because <code>ISO-8859-1</code> and <code>UTF-8</code> does not in general encode
the same characters as the same byte sequences.
</p>
<div class="example">
<pre class="example">jas@latte:~$ idn --quiet --debug &quot;&quot;
system locale uses charset `ISO-8859-1'.
 
jas@latte:~$ CHARSET=UTF-8 idn --quiet --debug r&auml;ksm&ouml;rg&aring;s
system locale uses charset `UTF-8'.
input[0] = U+0072
input[1] = U+4af3
input[2] = U+006d
input[3] = U+1b29e5
input[4] = U+0073
output[0] = U+0078
output[1] = U+006e
output[2] = U+002d
output[3] = U+002d
output[4] = U+0072
output[5] = U+006d
output[6] = U+0073
output[7] = U+002d
output[8] = U+0068
output[9] = U+0069
output[10] = U+0036
output[11] = U+0064
output[12] = U+0035
output[13] = U+0039
output[14] = U+0037
output[15] = U+0035
output[16] = U+0035
output[17] = U+0032
output[18] = U+0061
xn--rms-hi6d597552a
jas@latte:~$
</pre></div>

<p>The sense moral here is to forget about &lsquo;<samp>CHARSET</samp>&rsquo; (configure your
locales properly instead) unless you know what you are doing, and if
you want to use it, do it carefully, after verifying with
&lsquo;<samp>--debug</samp>&rsquo; that you get the desired results.
</p>
<hr>
<a name="Emacs-API"></a>
<div class="header">
<p>
Next: <a href="#Java-API" accesskey="n" rel="next">Java API</a>, Previous: <a href="#Invoking-idn" accesskey="p" rel="prev">Invoking idn</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Emacs-API-1"></a>
<h2 class="chapter">11 Emacs API</h2>

<p>Included in Libidn are <samp>punycode.el</samp> and <samp>idna.el</samp> that
provides an Emacs Lisp API to (a limited set of) the Libidn API.  This
section describes the API.  Currently the IDNA API always set the
<code>UseSTD3ASCIIRules</code> flag and clear the <code>AllowUnassigned</code>
flag, in the future there may be functionality to specify these flags
via the API.
</p>
<a name="Punycode-Emacs-API"></a>
<h3 class="section">11.1 Punycode Emacs API</h3>

<dl>
<dt><a name="index-punycode_002dprogram"></a>Variable: <strong>punycode-program</strong></dt>
<dd><p>Name of the GNU Libidn <samp>idn</samp> application.  The default is
&lsquo;<samp>idn</samp>&rsquo;.  This variable can be customized.
</p></dd></dl>

<dl>
<dt><a name="index-punycode_002denvironment"></a>Variable: <strong>punycode-environment</strong></dt>
<dd><p>List of environment variable definitions prepended to
&lsquo;<samp>process-environment</samp>&rsquo;.  The default is &lsquo;<samp>(&quot;CHARSET=UTF-8&quot;)</samp>&rsquo;.
This variable can be customized.
</p></dd></dl>

<dl>
<dt><a name="index-punycode_002dencode_002dparameters"></a>Variable: <strong>punycode-encode-parameters</strong></dt>
<dd><p>List of parameters passed to <var>punycode-program</var> to invoke punycode
encoding mode.  The default is &lsquo;<samp>(&quot;--quiet&quot; &quot;--punycode-encode&quot;)</samp>&rsquo;.
This variable can be customized.
</p></dd></dl>

<dl>
<dt><a name="index-punycode_002ddecode_002dparameters"></a>Variable: <strong>punycode-decode-parameters</strong></dt>
<dd><p>Parameters passed to <var>punycode-program</var> to invoke punycode
decoding mode.  The default is &lsquo;<samp>(&quot;--quiet&quot; &quot;--punycode-decode&quot;)</samp>&rsquo;.
This variable can be customized.
</p></dd></dl>

<dl>
<dt><a name="index-punycode_002dencode"></a>Function: <strong>punycode-encode</strong> <em>string</em></dt>
<dd><p>Returns a Punycode encoding of the <var>string</var>, after converting the
input into UTF-8.
</p></dd></dl>

<dl>
<dt><a name="index-punycode_002ddecode"></a>Function: <strong>punycode-decode</strong> <em>string</em></dt>
<dd><p>Returns a possibly multibyte string which is the decoding of the
<var>string</var> which is a punycode encoded string.
</p></dd></dl>

<a name="IDNA-Emacs-API"></a>
<h3 class="section">11.2 IDNA Emacs API</h3>

<dl>
<dt><a name="index-idna_002dprogram"></a>Variable: <strong>idna-program</strong></dt>
<dd><p>Name of the GNU Libidn <samp>idn</samp> application.  The default is
&lsquo;<samp>idn</samp>&rsquo;.  This variable can be customized.
</p></dd></dl>

<dl>
<dt><a name="index-idna_002denvironment"></a>Variable: <strong>idna-environment</strong></dt>
<dd><p>List of environment variable definitions prepended to
&lsquo;<samp>process-environment</samp>&rsquo;.  The default is &lsquo;<samp>(&quot;CHARSET=UTF-8&quot;)</samp>&rsquo;.
This variable can be customized.
</p></dd></dl>

<dl>
<dt><a name="index-idna_002dto_002dascii_002dparameters"></a>Variable: <strong>idna-to-ascii-parameters</strong></dt>
<dd><p>List of parameters passed to <var>idna-program</var> to invoke IDNA ToASCII
mode.  The default is &lsquo;<samp>(&quot;--quiet&quot; &quot;--idna-to-ascii&quot;
&quot;--usestd3asciirules&quot;)</samp>&rsquo;.  This variable can be customized.
</p></dd></dl>

<dl>
<dt><a name="index-idna_002dto_002dunicode_002dparameters"></a>Variable: <strong>idna-to-unicode-parameters</strong></dt>
<dd><p>Parameters passed <var>idna-program</var> to invoke IDNA ToUnicode mode.
The default is &lsquo;<samp>(&quot;--quiet&quot; &quot;--idna-to-unicode&quot;
&quot;--usestd3asciirules&quot;)</samp>&rsquo;.  This variable can be customized.
</p></dd></dl>

<dl>
<dt><a name="index-idna_002dto_002dascii"></a>Function: <strong>idna-to-ascii</strong> <em>string</em></dt>
<dd><p>Returns an ASCII Compatible Encoding (ACE) of the string computed by
the IDNA ToASCII operation on the input <var>string</var>, after converting
the input to UTF-8.
</p></dd></dl>

<dl>
<dt><a name="index-idna_002dto_002dunicode"></a>Function: <strong>idna-to-unicode</strong> <em>string</em></dt>
<dd><p>Returns a possibly multibyte string which is the output of the IDNA
ToUnicode operation computed on the input <var>string</var>.
</p></dd></dl>

<hr>
<a name="Java-API"></a>
<div class="header">
<p>
Next: <a href="#C_0023-API" accesskey="n" rel="next">C# API</a>, Previous: <a href="#Emacs-API" accesskey="p" rel="prev">Emacs API</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Java-API-1"></a>
<h2 class="chapter">12 Java API</h2>

<p>Libidn has been ported to the Java programming language, and as a
consequence most of the API is available to native Java applications.
This section contain notes on this support, complete documentation is
pending.
</p>
<p>The Java library, if Libidn has been built with Java support
(see <a href="#Downloading-and-Installing">Downloading and Installing</a>), will be placed in
<samp>java/libidn-1.34.jar</samp>.  The source code is below
<samp>java/</samp> in Maven directory layout, and there is a Maven
<samp>pom.xml</samp> build script as well.  Source code files are in
<samp>java/src/main/java/gnu/inet/encoding/</samp>.
</p>
<a name="Overview"></a>
<h3 class="section">12.1 Overview</h3>

<p>This package provides a Java implementation of the Internationalized
Domain Names in Applications (IDNA) standard. It is written entirely
in Java and does not require any additional libraries to be set up.
</p>
<p>The gnu.inet.encoding.IDNA class offers two public functions, toASCII
and toUnicode which can be used as follows:
</p>
<div class="example">
<pre class="example">gnu.inet.encoding.IDNA.toASCII(&quot;bl&ouml;ds.z&uuml;g&quot;);
gnu.inet.encoding.IDNA.toUnicode(&quot;xn--blds-6qa.xn--zg-xka&quot;);
</pre></div>

<a name="Miscellaneous-Programs"></a>
<h3 class="section">12.2 Miscellaneous Programs</h3>

<p>The <samp>java/src/util/java/</samp> directory contains several programs that
are related to the Java part of GNU Libidn, but that don&rsquo;t need to be
included in the main source tree or the JAR file.
</p>
<a name="GenerateRFC3454"></a>
<h4 class="subsection">12.2.1 GenerateRFC3454</h4>

<p>This program parses RFC3454 and creates the RFC3454.java program that
is required during the StringPrep phase.
</p>
<p>The RFC can be found at various locations, for example at
<a href="http://www.ietf.org/rfc/rfc3454.txt">http://www.ietf.org/rfc/rfc3454.txt</a>.
</p>
<p>Invoke the program as follows:
</p>
<div class="example">
<pre class="example">$ java GenerateRFC3454
Creating RFC3454.java... Ok.
</pre></div>

<a name="GenerateNFKC"></a>
<h4 class="subsection">12.2.2 GenerateNFKC</h4>

<p>The GenerateNFKC program parses the Unicode character database file
and generates all the tables required for NFKC. This program requires
the two files UnicodeData.txt and CompositionExclusions.txt of version
3.2 of the Unicode files. Note that RFC3454 (Stringprep) defines that
Unicode version 3.2 is to be used, not the latest version.
</p>
<p>The Unicode data files can be found at
<a href="http://www.unicode.org/Public/">http://www.unicode.org/Public/</a>.
</p>
<p>Invoke the program as follows:
</p>
<div class="example">
<pre class="example">$ java GenerateNFKC
Creating CombiningClass.java... Ok.
Creating DecompositionKeys.java... Ok.
Creating DecompositionMappings.java... Ok.
Creating Composition.java... Ok.
</pre></div>

<a name="TestIDNA"></a>
<h4 class="subsection">12.2.3 TestIDNA</h4>

<p>The TestIDNA program allows to test the IDNA implementation manually
or against Simon Josefsson&rsquo;s test vectors.
</p>
<p>The test vectors can be found at the Libidn homepage,
<a href="http://www.gnu.org/software/libidn/">http://www.gnu.org/software/libidn/</a>.
</p>
<p>To test the transformation manually, use:
</p>
<div class="example">
<pre class="example">$ java -cp .:/usr/share/java/libidn.jar TestIDNA -a &lt;string to test&gt;
Input: &lt;string to test&gt;
Output: &lt;toASCII(string to test)&gt;
$ java -cp .:/usr/share/java/libidn.jar TestIDNA -u &lt;string to test&gt;
Input: &lt;string to test&gt;
Output: &lt;toUnicode(string to test)&gt;
</pre></div>

<p>To test against draft-josefsson-idn-test-vectors.html, use:
</p>
<div class="example">
<pre class="example">$ java -cp .:/usr/share/java/libidn/libidn.jar TestIDNA -t
No errors detected!
</pre></div>

<a name="TestNFKC"></a>
<h4 class="subsection">12.2.4 TestNFKC</h4>

<p>The TestNFKC program allows to test the NFKC implementation manually
or against the NormalizationTest.txt file from the Unicode data files.
</p>
<p>To test the normalization manually, use:
</p>
<div class="example">
<pre class="example">$ java -cp .:/usr/share/java/libidn.jar TestNFKC &lt;string to test&gt;
Input: &lt;string to test&gt;
Output: &lt;nfkc version of the string to test&gt;
</pre></div>

<p>To test against NormalizationTest.txt:
</p>
<div class="example">
<pre class="example">$ java -cp .:/usr/share/java/libidn.jar TestNFKC
No errors detected!
</pre></div>

<a name="Possible-Problems"></a>
<h3 class="section">12.3 Possible Problems</h3>

<p>Beware of Bugs: This Java API needs a lot more testing, especially
with &quot;exotic&quot; character sets. While it works for me, it may not work
for you.
</p>
<p>Encoding of your Java sources: If you are using non-ASCII characters
in your Java source code, make sure javac compiles your programs with
the correct encoding. If necessary specify the encoding using the
-encoding parameter.
</p>
<p>Java Unicode handling: Java 1.4 only handles 16-bit Unicode code
points (i.e. characters in the Basic Multilingual Plane), this
implementation therefore ignores all references to so-called
Supplementary Characters (U+10000 to U+10FFFF). Starting from Java
1.5, these characters will also be supported by Java, but this will
require changes to this library.  See also the next section.
</p>
<a name="A-Note-on-Java-and-Unicode"></a>
<h3 class="section">12.4 A Note on Java and Unicode</h3>

<p>This library uses Java&rsquo;s built-in &rsquo;char&rsquo; datatype. Up to Java 1.4, this
datatype only supports 16-bit Unicode code points, also called the
Basic Multilingual Plane. For this reason, this library doesn&rsquo;t work
for Supplementary Characters (i.e. characters from U+10000 to
U+10FFFF). All references to such characters are silently ignored.
</p>
<p>Starting from Java 1.5, also Supplementary Characters will be
supported. However, this will require changes in the present version
of the library. Java 1.5 is currently in beta status.
</p>
<p>For more information refer to the documentation of java.lang.Character
in the JDK API.
</p>
<hr>
<a name="C_0023-API"></a>
<div class="header">
<p>
Next: <a href="#Acknowledgements" accesskey="n" rel="next">Acknowledgements</a>, Previous: <a href="#Java-API" accesskey="p" rel="prev">Java API</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="C_0023-API-1"></a>
<h2 class="chapter">13 C# API</h2>

<p>The Libidn library has been ported to the C# language.  The port
reside in the top-level <samp>csharp/</samp> directory.  Currently, no
further documentation about the implementation or the API is
available.  However, the C# port was based on the Java port, and the
API is exactly the same as in the Java version.  The help files for
the Java API may thus be useful.
</p>
<hr>
<a name="Acknowledgements"></a>
<div class="header">
<p>
Next: <a href="#History" accesskey="n" rel="next">History</a>, Previous: <a href="#C_0023-API" accesskey="p" rel="prev">C# API</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Acknowledgements-1"></a>
<h2 class="chapter">14 Acknowledgements</h2>

<p>The punycode implementation was taken from the IETF IDN Punycode
specification, by Adam M. Costello.  The TLD code was contributed by
Thomas Jacob.  The Java implementation was contributed by Oliver Hitz.
The C# implementation was contributed by Alexander Gnauck.  The
Unicode tables were provided by Unicode, Inc.  Some functions for
dealing with Unicode (see nfkc.c and toutf8.c) were borrowed from
GLib, downloaded from <a href="http://www.gtk.org/">http://www.gtk.org/</a>.  The manual borrowed
text from Libgcrypt by Werner Koch.
</p>
<p>Inspiration for many things that, consciously or not, have gone into
this package is due to a number of free software package that the
author has been exposed to.  The author wishes to acknowledge the free
software community in general, for giving an example on what role
software development can play in the modern society.
</p>
<p>Several people reported bugs, sent patches or suggested improvements,
see the file THANKS in the top-level directory of the source code.
</p>
<hr>
<a name="History"></a>
<div class="header">
<p>
Next: <a href="#PR29-discussion" accesskey="n" rel="next">PR29 discussion</a>, Previous: <a href="#Acknowledgements" accesskey="p" rel="prev">Acknowledgements</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="History-1"></a>
<h2 class="chapter">15 History</h2>

<p>The complete history of user visible changes is stored in the file
<samp>NEWS</samp> in the top-level directory of the source code tree.  The
complete history of modifications to each file is stored in the file
<samp>ChangeLog</samp> in the same directory.  This section contain a
condensed version of that information, in the form of &ldquo;milestones&rdquo;
for the project.
</p>
<dl compact="compact">
<dt>Stringprep implementation.</dt>
<dd><p>Version 0.0.0 released on 2002-11-05.
</p>
</dd>
<dt>IDNA and Punycode implementations, part of the GNU project.</dt>
<dd><p>Version 0.1.0 released on 2003-01-05.
</p>
</dd>
<dt>Uses official IDNA ACE prefix <code>xn--</code>.</dt>
<dd><p>Version 0.1.7 released on 2003-02-12.
</p>
</dd>
<dt>Command line interface.</dt>
<dd><p>Version 0.1.11 released on 2003-02-26.
</p>
</dd>
<dt>GNU Libc add-on proposed.</dt>
<dd><p>Version 0.1.12 released on 2003-03-06.
</p>
</dd>
<dt>Interoperability testing during IDNConnect.</dt>
<dd><p>Version 0.3.1 released on 2003-10-02.
</p>
</dd>
<dt>TLD restriction testing.</dt>
<dd><p>Version 0.4.0 released on 2004-02-28.
</p>
</dd>
<dt>GNU Libc add-on integrated.</dt>
<dd><p>Version 0.4.1 released on 2004-03-08.
</p>
</dd>
<dt>Native Java implementation.</dt>
<dd><p>Version 0.4.2-0.4.9 released between 2004-03-20 and 2004-06-11.
</p>
</dd>
<dt>PR-29 functions for &ldquo;problem sequences&rdquo;.</dt>
<dd><p>Version 0.5.0 released on 2004-06-26.
</p>
</dd>
<dt>Many small portability fixes and wider use.</dt>
<dd><p>Version 0.5.1 through 0.5.20, released between 2004-07-09 and
2005-10-23.
</p>
</dd>
<dt>Native C# implementation.</dt>
<dd><p>Version 0.6.0 released on 2005-12-03.
</p>
</dd>
<dt>Windows support through cross-compilation.</dt>
<dd><p>Version 0.6.1 released on 2006-01-20.
</p>
</dd>
<dt>Library declared stable by releasing v1.0.</dt>
<dd><p>Version 1.0 released on 2007-07-31.
</p>
</dd>
</dl>

<hr>
<a name="PR29-discussion"></a>
<div class="header">
<p>
Next: <a href="#On-Label-Separators" accesskey="n" rel="next">On Label Separators</a>, Previous: <a href="#History" accesskey="p" rel="prev">History</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="PR29-discussion-1"></a>
<h2 class="appendix">Appendix A PR29 discussion</h2>

<p>If you wish to experiment with a modified Unicode NFKC implementation
according to the PR29 proposal, you may find the following bug report
useful.  However, I have not verified that the suggested modifications
are correct.  For reference, I&rsquo;m including my response to the report
as well.
</p>
<pre class="verbatim">From: Rick McGowan &lt;rick@unicode.org&gt;
Subject: Possible bug and status of PR 29 change(s)
To: bug-libidn@gnu.org
Date: Wed, 27 Oct 2004 14:49:17 -0700

Hello. On behalf of the Unicode Consortium editorial committee, I would
like to find out more information about the PR 29 fixes, if any, and
functions in Libidn. Your implementation was listed in the text of PR29 as
needing investigation, so I am following up on several implementations.

The UTC has accepted the proposed fix to D2 as outlined in PR29, and a new
draft of UAX #15 has been issued.

I have looked at Libidn 0.5.8 (today), and there may still be a possible
bug in NFKC.java and nfkc.c.

------------------------------------------------------

1. In NFKC.java, this line in canonicalOrdering():

      if (i &gt; 0 &amp;&amp; (last_cc == 0 || last_cc != cc)) {

should perhaps be changed to:

      if (i &gt; 0 &amp;&amp; (last_cc == 0 || last_cc &lt; cc)) {

but I'm not sure of the sense of this comparison.

------------------------------------------------------

2. In nfkc.c, function _g_utf8_normalize_wc() has this code:

	  if (i &gt; 0 &amp;&amp;
	      (last_cc == 0 || last_cc != cc) &amp;&amp;
	      combine (wc_buffer[last_start], wc_buffer[i],
		       &amp;wc_buffer[last_start]))
	    {

This appears to have the same bug as the current Python implementation (in
Python 2.3.4). The code should be checking, as per new rule D2 UAX #15
update, that the next combining character is the same or HIGHER than the
current one. It now checks to see if it's non-zero and not equal.

The above line(s) should perhaps be changed to:

	  if (i &gt; 0 &amp;&amp;
	      (last_cc == 0 || last_cc &lt; cc) &amp;&amp;
	      combine (wc_buffer[last_start], wc_buffer[i],
		       &amp;wc_buffer[last_start]))
	    {

but I'm not sure of the sense of the comparison (&lt; or &gt; or &lt;=?) here.

In the text of PR29, I will be marking Libidn as &quot;needs change&quot; and adding
the version number that I checked. If any further change is made, please
let me know the release version, and I'll update again.

Regards,
	Rick McGowan
</pre>
<pre class="verbatim">From: Simon Josefsson &lt;jas@extundo.com&gt;
Subject: Re: Possible bug and status of PR 29 change(s)
To: Rick McGowan &lt;rick@unicode.org&gt;
Cc: bug-libidn@gnu.org
Date: Thu, 28 Oct 2004 09:47:47 +0200

Rick McGowan &lt;rick@unicode.org&gt; writes:

&gt; Hello. On behalf of the Unicode Consortium editorial committee, I would
&gt; like to find out more information about the PR 29 fixes, if any, and
&gt; functions in Libidn. Your implementation was listed in the text of PR29 as
&gt; needing investigation, so I am following up on several implementations.
&gt;
&gt; The UTC has accepted the proposed fix to D2 as outlined in PR29, and a new
&gt; draft of UAX #15 has been issued.
&gt;
&gt; I have looked at Libidn 0.5.8 (today), and there may still be a possible
&gt; bug in NFKC.java and nfkc.c.

Hello Rick.

I believe the current behavior is intentional.  Libidn do not aim to
implement latest-and-greatest NFKC, it aim to implement the NFKC
functionality required for StringPrep and IDN.  As you may know,
StringPrep/IDN reference Unicode 3.2.0, and explicitly says any later
changes (which I consider PR29 as) do not apply.

In fact, I believe that would I incorporate the changes suggested in
PR29, I would in fact be violating the IDN specifications.

Thanks for looking into the code and finding the place where the
change could be made.  I'll see if I can mention this in the manual
somewhere, for technically interested readers.

Regards,
Simon
</pre>
<hr>
<a name="On-Label-Separators"></a>
<div class="header">
<p>
Next: <a href="#Copying-Information" accesskey="n" rel="next">Copying Information</a>, Previous: <a href="#PR29-discussion" accesskey="p" rel="prev">PR29 discussion</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="On-Label-Separators-1"></a>
<h2 class="appendix">Appendix B On Label Separators</h2>

<p>Some strings contains characters whose NFKC normalized form contain
the ASCII dot (0x2E, &ldquo;.&rdquo;).  Examples of these characters are U+2024
(ONE DOT LEADER) and U+248C (DIGIT FIVE FULL STOP).  The strings have
the interesting property that their IDNA ToASCII output will contain
embedded dots.  For example:
</p>
<div class="example">
<pre class="example">ToASCII (hi U+248C com) = hi5.com
ToASCII (r&auml;ksm&ouml;rg&aring;s U+2024 com) = xn--rksmrgs.com-l8as9u
</pre></div>

<p>This demonstrate the two general cases: The first where the ASCII dot
is part of an output that do not begin with the IDN prefix
<code>xn--</code>.  The second example illustrate when the dot is part of
IDN prefixed with <code>xn--</code>.
</p>
<p>The input strings are, from the DNS point of view, a single label.
The IDNA algorithm translate one label at a time.  Thus, the output is
expected to be only one label.  What is important here is to make sure
the DNS resolver receives the correct query.  The DNS protocol does
not use the dot to delimit labels on the wire, rather it uses
length-value pairs.  Thus the correct query would be for
<code>{7}hi5.com</code> and <code>{22}xn--rksmrgs.com-l8as9u</code>
respectively.
</p>
<p>Some implementations <a name="DOCF1" href="#FOOT1"><sup>1</sup></a> have decided that
these inputs strings are potentially confusing for the user.  The
string <code>hi U+248C com</code> looks like <code>hi5.com</code> on systems that
support Unicode properly.  These implementations do not follow RFC
3490.  They yield:
</p>
<div class="example">
<pre class="example">ToASCII (hi U+248C com) = hi5.com
ToASCII (r&auml;ksm&ouml;rg&aring;s U+2024 com) = xn--rksmrgs-5wao1o.com
</pre></div>

<p>The DNS query they perform are <code>{3}hi5{3}com</code> and
<code>{18}xn--rksmrgs-5wao1o{3}com</code> respectively.  Arguably, this
leads to a better user experience, and suggests that the IDNA
specification is sub-optimal in this area.
</p>
<a name="Recommended-Workaround"></a>
<h3 class="section">B.1 Recommended Workaround</h3>

<p>It has been suggested to normalize the entire input string using NFKC
before passing it to IDNA ToASCII.  You may use
<code>stringprep_utf8_nfkc_normalize</code> or
<code>stringprep_ucs4_nfkc_normalize</code>.  This appears to lead to
similar behaviour as IE/Firefox, which would avoid the problem, but
this needs to be confirmed.  Feel free to discuss the issue with us.
</p>
<p>Alternative workarounds are being considered.  Eventually Libidn may
implement a new flag to the <code>idna_*</code> functions that implements a
recommended way to work around this problem.
</p>
<hr>
<a name="Copying-Information"></a>
<div class="header">
<p>
Next: <a href="#Function-and-Variable-Index" accesskey="n" rel="next">Function and Variable Index</a>, Previous: <a href="#On-Label-Separators" accesskey="p" rel="prev">On Label Separators</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Copying-Information-1"></a>
<h2 class="appendix">Appendix C Copying Information</h2>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#GNU-Free-Documentation-License" accesskey="1">GNU Free Documentation License</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">License for copying this manual.
</td></tr>
</table>

<hr>
<a name="GNU-Free-Documentation-License"></a>
<div class="header">
<p>
Up: <a href="#Copying-Information" accesskey="u" rel="up">Copying Information</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="GNU-Free-Documentation-License-1"></a>
<h3 class="appendixsec">C.1 GNU Free Documentation License</h3>

<a name="index-FDL_002c-GNU-Free-Documentation-License"></a>

<div align="center">Version 1.3, 3 November 2008
</div>

<div class="display">
<pre class="display">Copyright &copy; 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
<a href="https://fsf.org/">https://fsf.org/</a>

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
</pre></div>

<ol start="0">
<li> PREAMBLE

<p>The purpose of this License is to make a manual, textbook, or other
functional and useful document <em>free</em> in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
</p>
<p>This License is a kind of &ldquo;copyleft&rdquo;, which means that derivative
works of the document must themselves be free in the same sense.  It
complements the GNU General Public License, which is a copyleft
license designed for free software.
</p>
<p>We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does.  But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book.  We recommend this License
principally for works whose purpose is instruction or reference.
</p>
</li><li> APPLICABILITY AND DEFINITIONS

<p>This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License.  Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein.  The &ldquo;Document&rdquo;, below,
refers to any such manual or work.  Any member of the public is a
licensee, and is addressed as &ldquo;you&rdquo;.  You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
</p>
<p>A &ldquo;Modified Version&rdquo; of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
</p>
<p>A &ldquo;Secondary Section&rdquo; is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document&rsquo;s overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject.  (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.)  The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
</p>
<p>The &ldquo;Invariant Sections&rdquo; are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License.  If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant.  The Document may contain zero
Invariant Sections.  If the Document does not identify any Invariant
Sections then there are none.
</p>
<p>The &ldquo;Cover Texts&rdquo; are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License.  A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
</p>
<p>A &ldquo;Transparent&rdquo; copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters.  A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text.  A copy that is not &ldquo;Transparent&rdquo; is called &ldquo;Opaque&rdquo;.
</p>
<p>Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input
format, SGML or XML using a publicly available
DTD, and standard-conforming simple HTML,
PostScript or PDF designed for human modification.  Examples
of transparent image formats include PNG, XCF and
JPG.  Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, SGML or
XML for which the DTD and/or processing tools are
not generally available, and the machine-generated HTML,
PostScript or PDF produced by some word processors for
output purposes only.
</p>
<p>The &ldquo;Title Page&rdquo; means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page.  For works in
formats which do not have any title page as such, &ldquo;Title Page&rdquo; means
the text near the most prominent appearance of the work&rsquo;s title,
preceding the beginning of the body of the text.
</p>
<p>The &ldquo;publisher&rdquo; means any person or entity that distributes copies
of the Document to the public.
</p>
<p>A section &ldquo;Entitled XYZ&rdquo; means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language.  (Here XYZ stands for a
specific section name mentioned below, such as &ldquo;Acknowledgements&rdquo;,
&ldquo;Dedications&rdquo;, &ldquo;Endorsements&rdquo;, or &ldquo;History&rdquo;.)  To &ldquo;Preserve the Title&rdquo;
of such a section when you modify the Document means that it remains a
section &ldquo;Entitled XYZ&rdquo; according to this definition.
</p>
<p>The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document.  These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
</p>
</li><li> VERBATIM COPYING

<p>You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License.  You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute.  However, you may accept
compensation in exchange for copies.  If you distribute a large enough
number of copies you must also follow the conditions in section 3.
</p>
<p>You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
</p>
</li><li> COPYING IN QUANTITY

<p>If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document&rsquo;s license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover.  Both covers must also clearly and legibly identify
you as the publisher of these copies.  The front cover must present
the full title with all words of the title equally prominent and
visible.  You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
</p>
<p>If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
</p>
<p>If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
</p>
<p>It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
</p>
</li><li> MODIFICATIONS

<p>You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it.  In addition, you must do these things in the Modified Version:
</p>
<ol type="A" start="1">
<li> Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document).  You may use the same title as a previous version
if the original publisher of that version gives permission.

</li><li> List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.

</li><li> State on the Title page the name of the publisher of the
Modified Version, as the publisher.

</li><li> Preserve all the copyright notices of the Document.

</li><li> Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.

</li><li> Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.

</li><li> Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document&rsquo;s license notice.

</li><li> Include an unaltered copy of this License.

</li><li> Preserve the section Entitled &ldquo;History&rdquo;, Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page.  If
there is no section Entitled &ldquo;History&rdquo; in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.

</li><li> Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on.  These may be placed in the &ldquo;History&rdquo; section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.

</li><li> For any section Entitled &ldquo;Acknowledgements&rdquo; or &ldquo;Dedications&rdquo;, Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.

</li><li> Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles.  Section numbers
or the equivalent are not considered part of the section titles.

</li><li> Delete any section Entitled &ldquo;Endorsements&rdquo;.  Such a section
may not be included in the Modified Version.

</li><li> Do not retitle any existing section to be Entitled &ldquo;Endorsements&rdquo; or
to conflict in title with any Invariant Section.

</li><li> Preserve any Warranty Disclaimers.
</li></ol>

<p>If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant.  To do this, add their titles to the
list of Invariant Sections in the Modified Version&rsquo;s license notice.
These titles must be distinct from any other section titles.
</p>
<p>You may add a section Entitled &ldquo;Endorsements&rdquo;, provided it contains
nothing but endorsements of your Modified Version by various
parties&mdash;for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
</p>
<p>You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version.  Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity.  If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
</p>
<p>The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
</p>
</li><li> COMBINING DOCUMENTS

<p>You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
</p>
<p>The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy.  If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
</p>
<p>In the combination, you must combine any sections Entitled &ldquo;History&rdquo;
in the various original documents, forming one section Entitled
&ldquo;History&rdquo;; likewise combine any sections Entitled &ldquo;Acknowledgements&rdquo;,
and any sections Entitled &ldquo;Dedications&rdquo;.  You must delete all
sections Entitled &ldquo;Endorsements.&rdquo;
</p>
</li><li> COLLECTIONS OF DOCUMENTS

<p>You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
</p>
<p>You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
</p>
</li><li> AGGREGATION WITH INDEPENDENT WORKS

<p>A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an &ldquo;aggregate&rdquo; if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation&rsquo;s users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
</p>
<p>If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document&rsquo;s Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
</p>
</li><li> TRANSLATION

<p>Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections.  You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers.  In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
</p>
<p>If a section in the Document is Entitled &ldquo;Acknowledgements&rdquo;,
&ldquo;Dedications&rdquo;, or &ldquo;History&rdquo;, the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
</p>
</li><li> TERMINATION

<p>You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.
</p>
<p>However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
</p>
<p>Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
</p>
<p>Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
</p>
</li><li> FUTURE REVISIONS OF THIS LICENSE

<p>The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time.  Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.  See
<a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a>.
</p>
<p>Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License &ldquo;or any later version&rdquo; applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation.  If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.  If the Document
specifies that a proxy can decide which future versions of this
License can be used, that proxy&rsquo;s public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.
</p>
</li><li> RELICENSING

<p>&ldquo;Massive Multiauthor Collaboration Site&rdquo; (or &ldquo;MMC Site&rdquo;) means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works.  A
public wiki that anybody can edit is an example of such a server.  A
&ldquo;Massive Multiauthor Collaboration&rdquo; (or &ldquo;MMC&rdquo;) contained in the
site means any set of copyrightable works thus published on the MMC
site.
</p>
<p>&ldquo;CC-BY-SA&rdquo; means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
</p>
<p>&ldquo;Incorporate&rdquo; means to publish or republish a Document, in whole or
in part, as part of another Document.
</p>
<p>An MMC is &ldquo;eligible for relicensing&rdquo; if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole
or in part into the MMC, (1) had no cover texts or invariant sections,
and (2) were thus incorporated prior to November 1, 2008.
</p>
<p>The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
</p>
</li></ol>

<a name="ADDENDUM_003a-How-to-use-this-License-for-your-documents"></a>
<h3 class="heading">ADDENDUM: How to use this License for your documents</h3>

<p>To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
</p>
<div class="smallexample">
<pre class="smallexample">  Copyright (C)  <var>year</var>  <var>your name</var>.
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.3
  or any later version published by the Free Software Foundation;
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  Texts.  A copy of the license is included in the section entitled ``GNU
  Free Documentation License''.
</pre></div>

<p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the &ldquo;with&hellip;Texts.&rdquo; line with this:
</p>
<div class="smallexample">
<pre class="smallexample">    with the Invariant Sections being <var>list their titles</var>, with
    the Front-Cover Texts being <var>list</var>, and with the Back-Cover Texts
    being <var>list</var>.
</pre></div>

<p>If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
</p>
<p>If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
</p>

<hr>
<a name="Function-and-Variable-Index"></a>
<div class="header">
<p>
Next: <a href="#Concept-Index" accesskey="n" rel="next">Concept Index</a>, Previous: <a href="#Copying-Information" accesskey="p" rel="prev">Copying Information</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Function-and-Variable-Index-1"></a>
<h2 class="unnumbered">Function and Variable Index</h2>

<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Function-and-Variable-Index_fn_letter-I"><b>I</b></a>
 &nbsp; 
<a class="summary-letter" href="#Function-and-Variable-Index_fn_letter-P"><b>P</b></a>
 &nbsp; 
<a class="summary-letter" href="#Function-and-Variable-Index_fn_letter-S"><b>S</b></a>
 &nbsp; 
<a class="summary-letter" href="#Function-and-Variable-Index_fn_letter-T"><b>T</b></a>
 &nbsp; 
</td></tr></table>
<table class="index-fn" border="0">
<tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Function-and-Variable-Index_fn_letter-I">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_002dto_002dascii"><code>idna-to-ascii</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Emacs-API">Emacs API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_002dto_002dunicode"><code>idna-to-unicode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Emacs-API">Emacs API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fstrerror"><code>idna_strerror</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005fascii_005f4i"><code>idna_to_ascii_4i</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005fascii_005f4z"><code>idna_to_ascii_4z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005fascii_005f8z"><code>idna_to_ascii_8z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005fascii_005flz"><code>idna_to_ascii_lz</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005funicode_005f44i"><code>idna_to_unicode_44i</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005funicode_005f4z4z"><code>idna_to_unicode_4z4z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005funicode_005f8z4z"><code>idna_to_unicode_8z4z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005funicode_005f8z8z"><code>idna_to_unicode_8z8z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005funicode_005f8zlz"><code>idna_to_unicode_8zlz</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idna_005fto_005funicode_005flzlz"><code>idna_to_unicode_lzlz</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idn_005ffree"><code>idn_free</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Memory-handling-under-Windows">Memory handling under Windows</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Function-and-Variable-Index_fn_letter-P">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-pr29_005f4"><code>pr29_4</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#PR29-Functions">PR29 Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-pr29_005f4z"><code>pr29_4z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#PR29-Functions">PR29 Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-pr29_005f8z"><code>pr29_8z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#PR29-Functions">PR29 Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-pr29_005fstrerror"><code>pr29_strerror</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#PR29-Functions">PR29 Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-punycode_002ddecode"><code>punycode-decode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Emacs-API">Emacs API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-punycode_002dencode"><code>punycode-encode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Emacs-API">Emacs API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-punycode_005fdecode"><code>punycode_decode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Punycode-Functions">Punycode Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-punycode_005fencode"><code>punycode_encode</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Punycode-Functions">Punycode Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-punycode_005fstrerror"><code>punycode_strerror</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Punycode-Functions">Punycode Functions</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Function-and-Variable-Index_fn_letter-S">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep"><code>stringprep</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005f4i"><code>stringprep_4i</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005f4zi"><code>stringprep_4zi</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fcheck_005fversion"><code>stringprep_check_version</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Version-Check">Version Check</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fconvert"><code>stringprep_convert</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fiscsi"><code>stringprep_iscsi</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005flocale_005fcharset"><code>stringprep_locale_charset</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005flocale_005fto_005futf8"><code>stringprep_locale_to_utf8</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fnameprep_005fno_005funassigned"><code>stringprep_nameprep_no_unassigned</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fplain"><code>stringprep_plain</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fprofile"><code>stringprep_profile</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fstrerror"><code>stringprep_strerror</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fucs4_005fnfkc_005fnormalize"><code>stringprep_ucs4_nfkc_normalize</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fucs4_005fto_005futf8"><code>stringprep_ucs4_to_utf8</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005funichar_005fto_005futf8"><code>stringprep_unichar_to_utf8</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005futf8_005fnfkc_005fnormalize"><code>stringprep_utf8_nfkc_normalize</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005futf8_005fto_005flocale"><code>stringprep_utf8_to_locale</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005futf8_005fto_005fucs4"><code>stringprep_utf8_to_ucs4</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005futf8_005fto_005funichar"><code>stringprep_utf8_to_unichar</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fxmpp_005fnodeprep"><code>stringprep_xmpp_nodeprep</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-stringprep_005fxmpp_005fresourceprep"><code>stringprep_xmpp_resourceprep</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Function-and-Variable-Index_fn_letter-T">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fcheck_005f4"><code>tld_check_4</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fcheck_005f4t"><code>tld_check_4t</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fcheck_005f4tz"><code>tld_check_4tz</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fcheck_005f4z"><code>tld_check_4z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fcheck_005f8z"><code>tld_check_8z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fcheck_005flz"><code>tld_check_lz</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fdefault_005ftable"><code>tld_default_table</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fget_005f4"><code>tld_get_4</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fget_005f4z"><code>tld_get_4z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fget_005ftable"><code>tld_get_table</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fget_005fz"><code>tld_get_z</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tld_005fstrerror"><code>tld_strerror</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Function-and-Variable-Index_fn_letter-I"><b>I</b></a>
 &nbsp; 
<a class="summary-letter" href="#Function-and-Variable-Index_fn_letter-P"><b>P</b></a>
 &nbsp; 
<a class="summary-letter" href="#Function-and-Variable-Index_fn_letter-S"><b>S</b></a>
 &nbsp; 
<a class="summary-letter" href="#Function-and-Variable-Index_fn_letter-T"><b>T</b></a>
 &nbsp; 
</td></tr></table>

<hr>
<a name="Concept-Index"></a>
<div class="header">
<p>
Previous: <a href="#Function-and-Variable-Index" accesskey="p" rel="prev">Function and Variable Index</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Concept-Index-1"></a>
<h2 class="unnumbered">Concept Index</h2>

<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-U"><b>U</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a>
 &nbsp; 
</td></tr></table>
<table class="index-cp" border="0">
<tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-A">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-AIX">AIX</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-ARM">ARM</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Autoconf-tests">Autoconf tests</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Autoconf-tests">Autoconf tests</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-C">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-command-line">command line</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Invoking-idn">Invoking idn</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Compiling-your-application">Compiling your application</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Building-the-source">Building the source</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Configure-tests">Configure tests</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Autoconf-tests">Autoconf tests</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Contributing">Contributing</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Contributing">Contributing</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-D">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-de_002dallocation">de-allocation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Memory-handling-under-Windows">Memory handling under Windows</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Debian">Debian</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Debian-1">Debian</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Download">Download</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Downloading-and-Installing">Downloading and Installing</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-E">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-Examples">Examples</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Examples">Examples</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-F">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-FDL_002c-GNU-Free-Documentation-License">FDL, GNU Free Documentation License</a>:</td><td>&nbsp;</td><td valign="top"><a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-free">free</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Memory-handling-under-Windows">Memory handling under Windows</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-FreeBSD">FreeBSD</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-H">H</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-Hacking">Hacking</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Contributing">Contributing</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-heap-memory">heap memory</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Memory-handling-under-Windows">Memory handling under Windows</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-HP_002dUX">HP-UX</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-I">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-IBM">IBM</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-idn"><code>idn</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Invoking-idn">Invoking idn</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-IDNA-Functions">IDNA Functions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#IDNA-Functions">IDNA Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Installation">Installation</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Downloading-and-Installing">Downloading and Installing</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-invoking-idn">invoking <code>idn</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Invoking-idn">Invoking idn</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-IRIX">IRIX</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-M">M</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-MacOS-X">MacOS X</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-MacOS-X-1">MacOS X</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Mandrake">Mandrake</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Memory-handling">Memory handling</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Memory-handling-under-Windows">Memory handling under Windows</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Microsoft">Microsoft</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-mingw32">mingw32</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Motorola-Coldfire">Motorola Coldfire</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-N">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-NetBSD">NetBSD</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-O">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-OpenBSD">OpenBSD</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-OpenPower-720">OpenPower 720</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-OS_002f2">OS/2</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-P">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-PR29-Functions">PR29 Functions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#PR29-Functions">PR29 Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Punycode-Functions">Punycode Functions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Punycode-Functions">Punycode Functions</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-R">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-RedHat">RedHat</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-RedHat-1">RedHat</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-RedHat-2">RedHat</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-RedHat-Advanced-Server">RedHat Advanced Server</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Reporting-Bugs">Reporting Bugs</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Bug-Reports">Bug Reports</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-S">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-Solaris">Solaris</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Solaris-1">Solaris</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Solaris-2">Solaris</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Stringprep-Functions">Stringprep Functions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Stringprep-Functions">Stringprep Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-SuSE">SuSE</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-SuSE-Linux">SuSE Linux</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-SuSE-Linux-1">SuSE Linux</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-SuSE-Linux-2">SuSE Linux</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-T">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-TLD-Functions">TLD Functions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#TLD-Functions">TLD Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Tru64">Tru64</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-U">U</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-uClibc">uClibc</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-uClinux">uClinux</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Utility-Functions">Utility Functions</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Utility-Functions">Utility Functions</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-W">W</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-Windows">Windows</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Windows-1">Windows</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Supported-Platforms">Supported Platforms</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-N"><b>N</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-U"><b>U</b></a>
 &nbsp; 
<a class="summary-letter" href="#Concept-Index_cp_letter-W"><b>W</b></a>
 &nbsp; 
</td></tr></table>

<div class="footnote">
<hr>
<h4 class="footnotes-heading">Footnotes</h4>

<h3><a name="FOOT1" href="#DOCF1">(1)</a></h3>
<p>Notably Microsoft&rsquo;s Internet Explorer
and Mozilla&rsquo;s Firefox, but not Apple&rsquo;s Safari.</p>
</div>
<hr>



</body>
</html>

Hacked By AnonymousFox1.0, Coded By AnonymousFox