403Webshell
Server IP : 103.119.228.120  /  Your IP : 13.59.127.63
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /usr/share/doc/libidn-devel-1.28/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/share/doc/libidn-devel-1.28/libidn.html
<html lang="en">
<head>
<title>GNU Libidn 1.28</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="GNU Libidn 1.28">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="top" href="#Top">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual is last updated 10 July 2013 for version
1.28 of GNU Libidn.

Copyright (C) 2002-2013 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".
   -->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
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>
<h1 class="settitle">GNU Libidn 1.28</h1>
   <div class="contents">
<h2>Table of Contents</h2>
<ul>
<li><a name="toc_Top" href="#Top">GNU Libidn</a>
<li><a name="toc_Introduction" href="#Introduction">1 Introduction</a>
<ul>
<li><a href="#Getting-Started">1.1 Getting Started</a>
<li><a href="#Features">1.2 Features</a>
<li><a href="#Library-Overview">1.3 Library Overview</a>
<li><a href="#Supported-Platforms">1.4 Supported Platforms</a>
<li><a href="#Getting-help">1.5 Getting help</a>
<li><a href="#Commercial-Support">1.6 Commercial Support</a>
<li><a href="#Downloading-and-Installing">1.7 Downloading and Installing</a>
<ul>
<li><a href="#Installing-under-Windows">1.7.1 Installing under Windows</a>
</li></ul>
<li><a href="#Bug-Reports">1.8 Bug Reports</a>
<li><a href="#Contributing">1.9 Contributing</a>
</li></ul>
<li><a name="toc_Preparation" href="#Preparation">2 Preparation</a>
<ul>
<li><a href="#Header">2.1 Header</a>
<li><a href="#Initialization">2.2 Initialization</a>
<li><a href="#Version-Check">2.3 Version Check</a>
<li><a href="#Building-the-source">2.4 Building the source</a>
<li><a href="#Autoconf-tests">2.5 Autoconf tests</a>
<li><a href="#Memory-handling-under-Windows">2.6 Memory handling under Windows</a>
<li><a href="#Memory-handling-under-Windows">2.7 Header file <code>idn-free.h</code></a>
<li><a href="#Memory-handling-under-Windows">2.8 Memory de-allocation function</a>
</li></ul>
<li><a name="toc_Utility-Functions" href="#Utility-Functions">3 Utility Functions</a>
<ul>
<li><a href="#Utility-Functions">3.1 Header file <code>stringprep.h</code></a>
<li><a href="#Utility-Functions">3.2 Unicode Encoding Transformation</a>
<li><a href="#Utility-Functions">3.3 Unicode Normalization</a>
<li><a href="#Utility-Functions">3.4 Character Set Conversion</a>
</li></ul>
<li><a name="toc_Stringprep-Functions" href="#Stringprep-Functions">4 Stringprep Functions</a>
<ul>
<li><a href="#Stringprep-Functions">4.1 Header file <code>stringprep.h</code></a>
<li><a href="#Stringprep-Functions">4.2 Defining A Stringprep Profile</a>
<li><a href="#Stringprep-Functions">4.3 Control Flags</a>
<li><a href="#Stringprep-Functions">4.4 Core Functions</a>
<li><a href="#Stringprep-Functions">4.5 Error Handling</a>
<li><a href="#Stringprep-Functions">4.6 Stringprep Profile Macros</a>
</li></ul>
<li><a name="toc_Punycode-Functions" href="#Punycode-Functions">5 Punycode Functions</a>
<ul>
<li><a href="#Punycode-Functions">5.1 Header file <code>punycode.h</code></a>
<li><a href="#Punycode-Functions">5.2 Unicode Code Point Data Type</a>
<li><a href="#Punycode-Functions">5.3 Core Functions</a>
<li><a href="#Punycode-Functions">5.4 Error Handling</a>
</li></ul>
<li><a name="toc_IDNA-Functions" href="#IDNA-Functions">6 IDNA Functions</a>
<ul>
<li><a href="#IDNA-Functions">6.1 Header file <code>idna.h</code></a>
<li><a href="#IDNA-Functions">6.2 Control Flags</a>
<li><a href="#IDNA-Functions">6.3 Prefix String</a>
<li><a href="#IDNA-Functions">6.4 Core Functions</a>
<li><a href="#IDNA-Functions">6.5 Simplified ToASCII Interface</a>
<li><a href="#IDNA-Functions">6.6 Simplified ToUnicode Interface</a>
<li><a href="#IDNA-Functions">6.7 Error Handling</a>
</li></ul>
<li><a name="toc_TLD-Functions" href="#TLD-Functions">7 TLD Functions</a>
<ul>
<li><a href="#TLD-Functions">7.1 Header file <code>tld.h</code></a>
<li><a href="#TLD-Functions">7.2 Core Functions</a>
<li><a href="#TLD-Functions">7.3 Utility Functions</a>
<li><a href="#TLD-Functions">7.4 High-Level Wrapper Functions</a>
<li><a href="#TLD-Functions">7.5 Error Handling</a>
</li></ul>
<li><a name="toc_PR29-Functions" href="#PR29-Functions">8 PR29 Functions</a>
<ul>
<li><a href="#PR29-Functions">8.1 Header file <code>pr29.h</code></a>
<li><a href="#PR29-Functions">8.2 Core Functions</a>
<li><a href="#PR29-Functions">8.3 Utility Functions</a>
<li><a href="#PR29-Functions">8.4 Error Handling</a>
</li></ul>
<li><a name="toc_Examples" href="#Examples">9 Examples</a>
<ul>
<li><a href="#Example-1">9.1 Example 1</a>
<li><a href="#Example-2">9.2 Example 2</a>
<li><a href="#Example-3">9.3 Example 3</a>
<li><a href="#Example-4">9.4 Example 4</a>
<li><a href="#Example-5">9.5 Example 5</a>
</li></ul>
<li><a name="toc_Invoking-idn" href="#Invoking-idn">10 Invoking idn</a>
<ul>
<li><a href="#Invoking-idn">10.1 Name</a>
<li><a href="#Invoking-idn">10.2 Description</a>
<li><a href="#Invoking-idn">10.3 Options</a>
<li><a href="#Invoking-idn">10.4 Environment Variables</a>
<li><a href="#Invoking-idn">10.5 Examples</a>
<li><a href="#Invoking-idn">10.6 Troubleshooting</a>
</li></ul>
<li><a name="toc_Emacs-API" href="#Emacs-API">11 Emacs API</a>
<ul>
<li><a href="#Emacs-API">11.1 Punycode Emacs API</a>
<li><a href="#Emacs-API">11.2 IDNA Emacs API</a>
</li></ul>
<li><a name="toc_Java-API" href="#Java-API">12 Java API</a>
<ul>
<li><a href="#Java-API">12.1 Overview</a>
<li><a href="#Java-API">12.2 Miscellaneous Programs</a>
<ul>
<li><a href="#Java-API">12.2.1 GenerateRFC3454</a>
<li><a href="#Java-API">12.2.2 GenerateNFKC</a>
<li><a href="#Java-API">12.2.3 TestIDNA</a>
<li><a href="#Java-API">12.2.4 TestNFKC</a>
</li></ul>
<li><a href="#Java-API">12.3 Possible Problems</a>
<li><a href="#Java-API">12.4 A Note on Java and Unicode</a>
</li></ul>
<li><a name="toc_C_0023-API" href="#C_0023-API">13 C# API</a>
<li><a name="toc_Acknowledgements" href="#Acknowledgements">14 Acknowledgements</a>
<li><a name="toc_History" href="#History">15 History</a>
<li><a name="toc_PR29-discussion" href="#PR29-discussion">Appendix A PR29 discussion</a>
<li><a name="toc_On-Label-Separators" href="#On-Label-Separators">Appendix B On Label Separators</a>
<ul>
<li><a href="#On-Label-Separators">B.1 Recommended Workaround</a>
</li></ul>
<li><a name="toc_Copying-Information" href="#Copying-Information">Appendix C Copying Information</a>
<ul>
<li><a href="#GNU-Free-Documentation-License">C.1 GNU Free Documentation License</a>
</li></ul>
<li><a name="toc_Function-and-Variable-Index" href="#Function-and-Variable-Index">Function and Variable Index</a>
<li><a name="toc_Concept-Index" href="#Concept-Index">Concept Index</a>
</li></ul>
</div>



<div class="node">
<a name="Top"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>

</div>

<h2 class="unnumbered">GNU Libidn</h2>

<p>This manual is last updated 10 July 2013 for version
1.28 of GNU Libidn.

   <p>Copyright &copy; 2002-2013 Simon Josefsson.

   <blockquote>
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;. 
</blockquote>

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

</li></ul>
<p>Appendices

</p>
<ul class="menu">
<li><a href="#PR29-discussion">PR29 discussion</a>:              Implementation aspects of the PR29 flaw. 
<li><a href="#On-Label-Separators">On Label Separators</a>:          Discussions of a flaw in the IDNA spec. 
<li><a href="#Copying-Information">Copying Information</a>: 		License texts.

</li></ul>
<p>Indices

</p>
<ul class="menu">
<li><a href="#Function-and-Variable-Index">Function and Variable Index</a>
<li><a href="#Concept-Index">Concept Index</a>

   </ul>

<div class="node">
<a name="Introduction"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Preparation">Preparation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Top">Top</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">1 Introduction</h2>

<p>GNU Libidn is a fully documented implementation of the Stringprep,
Punycode and IDNA specifications.  Libidn's purpose is to encode and
decode internationalized domain name strings.  There are native C, C#
and Java libraries.

   <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>The Stringprep API consists of two main functions, one for converting
data from the system'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>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>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>Also included is a command line tool, several self tests, code
examples, and more.

<ul class="menu">
<li><a accesskey="1" href="#Getting-Started">Getting Started</a>
<li><a accesskey="2" href="#Features">Features</a>
<li><a accesskey="3" href="#Library-Overview">Library Overview</a>
<li><a accesskey="4" href="#Supported-Platforms">Supported Platforms</a>
<li><a accesskey="5" href="#Getting-help">Getting help</a>
<li><a accesskey="6" href="#Commercial-Support">Commercial Support</a>
<li><a accesskey="7" href="#Downloading-and-Installing">Downloading and Installing</a>
<li><a accesskey="8" href="#Bug-Reports">Bug Reports</a>
<li><a accesskey="9" href="#Contributing">Contributing</a>
</ul>

<div class="node">
<a name="Getting-Started"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Features">Features</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<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><span class="file">idn</span></samp> that provide a quick interface to the library.  The
Emacs Lisp bindings for the library is also discussed.

   <p>The reader is assumed to possess basic familiarity with
internationalization concepts and network programming in C or C++.

   <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.

<div class="node">
<a name="Features"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Library-Overview">Library Overview</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Getting-Started">Getting Started</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.2 Features</h3>

<p>This library might have a couple of advantages over other libraries
doing a similar job.

     <dl>
<dt>It's Free Software<dd>Anybody can use, modify, and redistribute it under the terms of a free
software license.

     <br><dt>It's thread-safe<dd>No global state is kept in the library.  All functions are re-entrant.

     <br><dt>It's portable<dd>The code is intended to be written in pure ANSI C89.  It has been
tested on many Unix like operating systems, and Windows.

     <br><dt>It's modularized<dd>The library is composed of several modules, and the only interaction
between modules is through each modules' 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.

     <br><dt>It's not bloated<dd>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.

     <br><dt>It's documented<dd>Sadly, not all software comes with documentation these days.  This one
does.

   </dl>

<div class="node">
<a name="Library-Overview"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Supported-Platforms">Supported Platforms</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Features">Features</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<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.

   <div class="block-image"><img src="libidn-components.png" alt="libidn-components.png"></div>

<div class="node">
<a name="Supported-Platforms"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Getting-help">Getting help</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Library-Overview">Library Overview</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<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>.

     <ol type=1 start=1>

     <li>Debian GNU/Linux 3.0 (Woody)
<a name="index-Debian-1"></a>
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>.

     <li>Debian GNU/Linux 2.1
<a name="index-Debian-2"></a>
GCC 2.95.1 and GNU Make. <code>armv4l-unknown-linux-gnu</code>.

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

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

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

     <li>SuSE Linux
<a name="index-SuSE-Linux-6"></a>
GCC 3.2.2 and GNU Make.  <code>x86_64-unknown-linux-gnu</code> (AMD64
Opteron &ldquo;Melody&rdquo;).

     <li>SuSE Enterprise Server 9 on IBM OpenPower 720
<a name="index-SuSE-Linux-7"></a><a name="index-OpenPower-720-8"></a>
GCC 3.3.3 and GNU Make.  <code>powerpc64-unknown-linux-gnu</code>.

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

     <li>RedHat Linux 8.0
<a name="index-RedHat-10"></a>
GCC 3.2 and GNU Make. <code>i686-pc-linux-gnu</code>.

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

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

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

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

     <li>AIX 4.3.2
<a name="index-AIX-15"></a>
IBM C for AIX compiler, AIX Make.  <code>rs6000-ibm-aix4.3.2.0</code>.

     <li>Microsoft Windows 2000 (Cygwin)
<a name="index-Windows-16"></a>
GCC 3.2, GNU make. <code>i686-pc-cygwin</code>.

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

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

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

     <li>SUN Solaris 2.9
<a name="index-Solaris-20"></a>
Sun Forte Developer 7 C compiler and GNU
Make. <code>sparc-sun-solaris2.9</code>.

     <li>NetBSD 1.6
<a name="index-NetBSD-21"></a>
GCC 2.95.3 and GNU Make. <code>alpha-unknown-netbsd1.6</code>,
<code>i386-unknown-netbsdelf1.6</code>.

     <li>OpenBSD 3.1 and 3.2
<a name="index-OpenBSD-22"></a>
GCC 2.95.3 and GNU Make. <code>alpha-unknown-openbsd3.1</code>,
<code>i386-unknown-openbsd3.1</code>.

     <li>FreeBSD 4.7 and 4.8
<a name="index-FreeBSD-23"></a>
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>.

     <li>MacOS X 10.2 Server Edition
<a name="index-MacOS-X-24"></a>
GCC 3.1 and GNU Make. <code>powerpc-apple-darwin6.5</code>.

     <li>MacOS X 10.4 &ldquo;Tiger&rdquo; with Xcode 2.0
<a name="index-MacOS-X-25"></a>
GCC 4.0 and GNU Make. <code>powerpc-apple-darwin8.0</code>.

     <li>Cross compiled to uClinux/uClibc on Motorola Coldfire
<a name="index-Motorola-Coldfire-26"></a><a name="index-uClinux-27"></a><a name="index-uClibc-28"></a>
GCC 3.4 and GNU Make <code>m68k-uclinux-elf</code>.

     <li>Cross compiled to ARM using Glibc
<a name="index-ARM-29"></a>
GCC 2.95 and GNU Make <code>arm-linux</code>.

     <li>Cross compiled to Mingw32. 
<a name="index-Windows-30"></a><a name="index-Microsoft-31"></a><a name="index-mingw32-32"></a>
GCC 3.4.4 and GNU Make <code>i586-mingw32msvc</code>.

     <li>OS/2
<a name="index-OS_002f2-33"></a><a name="index-IBM-34"></a>
GCC.

        </ol>

   <p>If you use Libidn on, or port Libidn to, a new platform please report
it to the author.

<div class="node">
<a name="Getting-help"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Commercial-Support">Commercial Support</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Supported-Platforms">Supported Platforms</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<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>.

<div class="node">
<a name="Commercial-Support"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Downloading-and-Installing">Downloading and Installing</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Getting-help">Getting help</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<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:

     <ul>
<li>Implement new features. 
Such as country code specific profiling to support a restricted subset
of Unicode.

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

     <li>Integrating IDN support in your existing project.

     <li>System design of components related to IDN.

   </ul>

   <p>If you are interested, please write to:

<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>).

<div class="node">
<a name="Downloading-and-Installing"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Bug-Reports">Bug Reports</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Commercial-Support">Commercial Support</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.7 Downloading and Installing</h3>

<p><a name="index-Installation-35"></a><a name="index-Download-36"></a>
The package can be downloaded from several places, including:

   <p><a href="ftp://alpha.gnu.org/pub/gnu/libidn/">ftp://alpha.gnu.org/pub/gnu/libidn/</a>

   <p>The latest version is stored in a file, e.g.,
&lsquo;<samp><span class="samp">libidn-1.28.tar.gz</span></samp>&rsquo; where the &lsquo;<samp><span class="samp">1.28</span></samp>&rsquo;
value is the highest version number in the directory.

   <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><span class="file">INSTALL</span></samp> file that is part of the
distribution archive.

   <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><span class="samp">sh</span></samp>&rsquo;, &lsquo;<samp><span class="samp">make</span></samp>&rsquo; and &lsquo;<samp><span class="samp">cc</span></samp>&rsquo;.

<pre class="example">     $ wget -q ftp://alpha.gnu.org/pub/gnu/libidn/libidn-1.28.tar.gz
     $ tar xfz libidn-1.28.tar.gz
     $ cd libidn-1.28/
     $ ./configure
     ...
     $ make
     ...
     $ make install
     ...
</pre>
   <p>After that Libidn should be properly installed and ready for use.

   <p>A few <code>configure</code> options may be relevant, summarized in the
table.

     <dl>
<dt><code>--enable-java</code><dd>Build the Java port into a *.JAR file.  See <a href="#Java-API">Java API</a>, for more
information.

     <br><dt><code>--disable-tld</code><dd>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.

     <br><dt><code>--enable-csharp[=IMPL]</code><dd>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 <samp><span class="command">cscc</span></samp> compiler or the Mono
<samp><span class="command">mcs</span></samp> compiler should be used, respectively.

     <br><dt><code>--disable-valgrind-tests</code><dd>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.

   </dl>

   <p>For the complete list, refer to the output from <code>configure
--help</code>.

<ul class="menu">
<li><a accesskey="1" href="#Installing-under-Windows">Installing under Windows</a>:     Windows specific build instructions. 
</ul>

<div class="node">
<a name="Installing-under-Windows"></a>
<p><hr>
Up:&nbsp;<a rel="up" accesskey="u" href="#Downloading-and-Installing">Downloading and Installing</a>

</div>

<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>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>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>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>First download and unpack the archive as described in the generic
installation instructions (see <a href="#Downloading-and-Installing">Downloading and Installing</a>).  Don't
run <code>./configure</code>.  Instead, start Visual Studio and open the
project file <samp><span class="file">windows/libidn.sln</span></samp> inside the Libidn directory.  You
should be able to build the project using Build Project.

   <p>Output libraries will be written into the <code>windows/lib</code> (or
<code>windows/lib/debug</code> for Debug versions) folder.

   <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>).

<div class="node">
<a name="Bug-Reports"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Contributing">Contributing</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Downloading-and-Installing">Downloading and Installing</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.8 Bug Reports</h3>

<p><a name="index-Reporting-Bugs-37"></a>
If you think you have found a bug in Libidn, please investigate it and
report it.

     <ul>
<li>Please make sure that the bug is really in Libidn, and
preferably also check that it hasn't already been fixed in the latest
version.

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

     <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.

   </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't help the
development effort.

   <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't
do anything about it (apart from asking you to send better bug
reports).

   <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>Send your bug report to:

<div align="center">&lsquo;<samp><span class="samp">bug-libidn@gnu.org</span></samp>&rsquo;</div>

<div class="node">
<a name="Contributing"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Bug-Reports">Bug Reports</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.9 Contributing</h3>

<p><a name="index-Contributing-38"></a><a name="index-Hacking-39"></a>
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>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>For contributions that doesn't consist of actual programming code, the
only guidelines are common sense.  Use it.

   <p>For code contributions, a number of style guides will help you:

     <ul>
<li>Coding Style. 
Follow the GNU Standards document (see <a href="standards.html#Top">GNU Coding Standards</a>).

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

     <li>Use the unified diff format &lsquo;<samp><span class="samp">diff -u</span></samp>&rsquo;.

     <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>Design with thread safety in mind. 
Don't use global variables and the like.

     <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>Document your functions. 
Use comments before each function headers, that, if properly
formatted, are extracted into GTK-DOC web pages.  Don't forget to
update the Texinfo manual as well.

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

   </ul>

<!-- ********************************************************** -->
<!-- *******************  Preparation  ************************ -->
<!-- ********************************************************** -->
<div class="node">
<a name="Preparation"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Utility-Functions">Utility Functions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">2 Preparation</h2>

<p>To use `Libidn', 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>A faster way to find out how to adapt your application for use with
`Libidn' may be to look at the examples at the end of this manual
(see <a href="#Examples">Examples</a>).

<ul class="menu">
<li><a accesskey="1" href="#Header">Header</a>
<li><a accesskey="2" href="#Initialization">Initialization</a>
<li><a accesskey="3" href="#Version-Check">Version Check</a>
<li><a accesskey="4" href="#Building-the-source">Building the source</a>
<li><a accesskey="5" href="#Autoconf-tests">Autoconf tests</a>
<li><a accesskey="6" href="#Memory-handling-under-Windows">Memory handling under Windows</a>
</ul>

<div class="node">
<a name="Header"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Initialization">Initialization</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Preparation">Preparation</a>

</div>

<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:

<pre class="example">     #include &lt;stringprep.h&gt;
</pre>
   <p>The header files and the functions they define are categorized as
follows:

     <dl>
<dt>stringprep.h<dd>
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>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.

     <br><dt>punycode.h<dd>
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>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. 
<br><dt>idna.h<dd>
The entry point to the IDNA functions.  This is the normal entry point
for applications that need IDN functionality.

     <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.

     <br><dt>tld.h<dd>
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>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.

     <br><dt>pr29.h<dd>
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>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.

     <br><dt>idn-free.h<dd>
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>.

   </dl>

   <p>All header files defined and use the symbol <code>IDNAPI</code> to decorate
the API functions.

<div class="node">
<a name="Initialization"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Version-Check">Version Check</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Header">Header</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Preparation">Preparation</a>

</div>

<h3 class="section">2.2 Initialization</h3>

<p>Libidn is stateless and does not need any initialization.

<div class="node">
<a name="Version-Check"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Building-the-source">Building the source</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Initialization">Initialization</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Preparation">Preparation</a>

</div>

<h3 class="section">2.3 Version Check</h3>

<p>It is often desirable to check that the version of `Libidn' 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.

<h4 class="subheading">stringprep_check_version</h4>

<p><a name="stringprep_005fcheck_005fversion"></a>

<div class="defun">
&mdash; Function: const char * <b>stringprep_check_version</b> (<var>const char * req_version</var>)<var><a name="index-stringprep_005fcheck_005fversion-40"></a></var><br>
<blockquote><p><var>req_version</var>: Required version number, or NULL.

        <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>See <code>STRINGPREP_VERSION</code> for a suitable <code>req_version</code> string.

        <p><strong>Return value:</strong> Version string of run-time library, or NULL if the
run-time library does not meet the required version number. 
</p></blockquote></div>

   <p>The normal way to use the function is to put something similar to the
following first in your <code>main</code>:

<pre class="example">       if (!stringprep_check_version (STRINGPREP_VERSION))
         {
           printf ("stringprep_check_version() failed:\n"
                   "Header file incompatible with shared library.\n");
           exit(EXIT_FAILURE);
         }
</pre>
   <div class="node">
<a name="Building-the-source"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Autoconf-tests">Autoconf tests</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Version-Check">Version Check</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Preparation">Preparation</a>

</div>

<h3 class="section">2.4 Building the source</h3>

<p><a name="index-Compiling-your-application-41"></a>
If you want to compile a source file including e.g. the `idna.h' 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><span class="option">-I</span></samp> option).

   <p>However, the path to the include file is determined at the time the
source is configured.  To solve this problem, `Libidn' uses the
external package <samp><span class="command">pkg-config</span></samp> 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><span class="option">--cflags</span></samp> option to <samp><span class="command">pkg-config libidn</span></samp>.  The
following example shows how it can be used at the command line:

<pre class="example">     gcc -c foo.c `pkg-config libidn --cflags`
</pre>
   <p>Adding the output of &lsquo;<samp><span class="samp">pkg-config libidn --cflags</span></samp>&rsquo; to the
compilers command line will ensure that the compiler can find e.g. the
idna.h header file.

   <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><span class="option">-L</span></samp> option).  For this, the option
<samp><span class="option">--libs</span></samp> to <samp><span class="command">pkg-config libidn</span></samp> can be used.  For
convenience, this option also outputs all other options that are
required to link the program with the `libidn' library.  The example
shows how to link <samp><span class="file">foo.o</span></samp> with the `libidn' library to a program
<samp><span class="command">foo</span></samp>.

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

<pre class="example">     gcc -o foo foo.c `pkg-config libidn --cflags --libs`
</pre>
   <div class="node">
<a name="Autoconf-tests"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Memory-handling-under-Windows">Memory handling under Windows</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Building-the-source">Building the source</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Preparation">Preparation</a>

</div>

<h3 class="section">2.5 Autoconf tests</h3>

<p><a name="index-Autoconf-tests-42"></a><a name="index-Configure-tests-43"></a>
If your project uses Autoconf (see <a href="autoconf.html#Top">GNU Autoconf</a>)
to check for installed libraries, you might find the following snippet
illustrative.  It add a new <samp><span class="file">configure</span></samp> parameter
<code>--with-libidn</code>, and check for <samp><span class="file">idna.h</span></samp> and &lsquo;<samp><span class="samp">-lidn</span></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><span class="samp">libidn=yes</span></samp>&rsquo; to &lsquo;<samp><span class="samp">libidn=no</span></samp>&rsquo; on the third
line.

<pre class="example">     AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]],
                                     [Support IDN (needs GNU Libidn)]),
       libidn=$withval, libidn=yes)
     if test "$libidn" != "no"; then
       if test "$libidn" != "yes"; then
         LDFLAGS="${LDFLAGS} -L$libidn/lib"
         CPPFLAGS="${CPPFLAGS} -I$libidn/include"
       fi
       AC_CHECK_HEADER(idna.h,
         AC_CHECK_LIB(idn, stringprep_check_version,
           [libidn=yes LIBS="${LIBS} -lidn"], libidn=no),
         libidn=no)
     fi
     if test "$libidn" != "no" ; 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>
   <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.

<pre class="example">     AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]],
                                     [Support IDN (needs GNU Libidn)]),
       libidn=$withval, libidn=yes)
     if test "$libidn" != "no" ; then
       PKG_CHECK_MODULES(LIBIDN, libidn &gt;= 0.0.0, [libidn=yes], [libidn=no])
       if test "$libidn" != "yes" ; 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 class="node">
<a name="Memory-handling-under-Windows"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Autoconf-tests">Autoconf tests</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Preparation">Preparation</a>

</div>

<h3 class="section">2.6 Memory handling under Windows</h3>

<p><a name="index-free-44"></a><a name="index-Memory-handling-45"></a><a name="index-de_002dallocation-46"></a><a name="index-heap-memory-47"></a>
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>Note that we do not recommend using this interface generally if you do
not care about Windows portability.

<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><span class="file">idn-free.h</span></samp> using:

<pre class="example">     #include &lt;idn-free.h&gt;
</pre>
   <h3 class="section">2.8 Memory de-allocation function</h3>

<h4 class="subheading">idn_free</h4>

<p><a name="idn_005ffree"></a>

<div class="defun">
&mdash; Function: void <b>idn_free</b> (<var>void * ptr</var>)<var><a name="index-idn_005ffree-48"></a></var><br>
<blockquote><p><var>ptr</var>: memory region to deallocate, or <code>NULL</code>.

        <p>Deallocates memory region by calling <code>free()</code>.  If <code>ptr</code> is <code>NULL</code> no
operation is performed.

        <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></blockquote></div>

<!-- ********************************************************** -->
<!-- ********************  Utility Functions ****************** -->
<!-- ********************************************************** -->
<div class="node">
<a name="Utility-Functions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Stringprep-Functions">Stringprep Functions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Preparation">Preparation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">3 Utility Functions</h2>

<p><a name="index-Utility-Functions-49"></a>
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.

<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><span class="file">stringprep.h</span></samp> using:

<pre class="example">     #include &lt;stringprep.h&gt;
</pre>
   <h3 class="section">3.2 Unicode Encoding Transformation</h3>

<h4 class="subheading">stringprep_unichar_to_utf8</h4>

<p><a name="stringprep_005funichar_005fto_005futf8"></a>

<div class="defun">
&mdash; Function: int <b>stringprep_unichar_to_utf8</b> (<var>uint32_t c, char * outbuf</var>)<var><a name="index-stringprep_005funichar_005fto_005futf8-50"></a></var><br>
<blockquote><p><var>c</var>: a ISO10646 character code

        <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>Converts a single character to UTF-8.

        <p><strong>Return value:</strong> number of bytes written. 
</p></blockquote></div>

<h4 class="subheading">stringprep_utf8_to_unichar</h4>

<p><a name="stringprep_005futf8_005fto_005funichar"></a>

<div class="defun">
&mdash; Function: uint32_t <b>stringprep_utf8_to_unichar</b> (<var>const char * p</var>)<var><a name="index-stringprep_005futf8_005fto_005funichar-51"></a></var><br>
<blockquote><p><var>p</var>: a pointer to Unicode character encoded as UTF-8

        <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><strong>Return value:</strong> the resulting character. 
</p></blockquote></div>

<h4 class="subheading">stringprep_ucs4_to_utf8</h4>

<p><a name="stringprep_005fucs4_005fto_005futf8"></a>

<div class="defun">
&mdash; Function: char * <b>stringprep_ucs4_to_utf8</b> (<var>const uint32_t * str, ssize_t len, size_t * items_read, size_t * items_written</var>)<var><a name="index-stringprep_005fucs4_005fto_005futf8-52"></a></var><br>
<blockquote><p><var>str</var>: a UCS-4 encoded string

        <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><var>items_read</var>: location to store number of characters read read, or <code>NULL</code>.

        <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>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><strong>Return value:</strong> 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></blockquote></div>

<h4 class="subheading">stringprep_utf8_to_ucs4</h4>

<p><a name="stringprep_005futf8_005fto_005fucs4"></a>

<div class="defun">
&mdash; Function: uint32_t * <b>stringprep_utf8_to_ucs4</b> (<var>const char * str, ssize_t len, size_t * items_written</var>)<var><a name="index-stringprep_005futf8_005fto_005fucs4-53"></a></var><br>
<blockquote><p><var>str</var>: a UTF-8 encoded string

        <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><var>items_written</var>: location to store the number of characters in the
result, or <code>NULL</code>.

        <p>Convert a string from UTF-8 to a 32-bit fixed width
representation as UCS-4, assuming valid UTF-8 input. 
This function does no error checking on the input.

        <p><strong>Return value:</strong> a pointer to a newly allocated UCS-4 string. 
This value must be deallocated by the caller. 
</p></blockquote></div>

<h3 class="section">3.3 Unicode Normalization</h3>

<h4 class="subheading">stringprep_ucs4_nfkc_normalize</h4>

<p><a name="stringprep_005fucs4_005fnfkc_005fnormalize"></a>

<div class="defun">
&mdash; Function: uint32_t * <b>stringprep_ucs4_nfkc_normalize</b> (<var>const uint32_t * str, ssize_t len</var>)<var><a name="index-stringprep_005fucs4_005fnfkc_005fnormalize-54"></a></var><br>
<blockquote><p><var>str</var>: a Unicode string.

        <p><var>len</var>: length of <code>str</code> array, or -1 if <code>str</code> is nul-terminated.

        <p>Converts a UCS4 string into canonical form, see
<code>stringprep_utf8_nfkc_normalize()</code> for more information.

        <p><strong>Return value:</strong> a newly allocated Unicode string, that is the NFKC
normalized form of <code>str</code>. 
</p></blockquote></div>

<h4 class="subheading">stringprep_utf8_nfkc_normalize</h4>

<p><a name="stringprep_005futf8_005fnfkc_005fnormalize"></a>

<div class="defun">
&mdash; Function: char * <b>stringprep_utf8_nfkc_normalize</b> (<var>const char * str, ssize_t len</var>)<var><a name="index-stringprep_005futf8_005fnfkc_005fnormalize-55"></a></var><br>
<blockquote><p><var>str</var>: a UTF-8 encoded string.

        <p><var>len</var>: length of <code>str</code>, in bytes, or -1 if <code>str</code> is nul-terminated.

        <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>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
"compatibility" 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><strong>Return value:</strong> a newly allocated string, that is the
NFKC normalized form of <code>str</code>. 
</p></blockquote></div>

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

<h4 class="subheading">stringprep_locale_charset</h4>

<p><a name="stringprep_005flocale_005fcharset"></a>

<div class="defun">
&mdash; Function: const char * <b>stringprep_locale_charset</b> (<var> void</var>)<var><a name="index-stringprep_005flocale_005fcharset-56"></a></var><br>
<blockquote>
        <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 "ASCII" if CHARSET isn't set and
nl_langinfo isn't supported or return anything.

        <p>Note that this function return the application's locale's preferred
charset (or thread's locale'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><strong>Return value:</strong> Return the character set used by the current locale. 
It will never return NULL, but use "ASCII" as a fallback. 
</p></blockquote></div>

<h4 class="subheading">stringprep_convert</h4>

<p><a name="stringprep_005fconvert"></a>

<div class="defun">
&mdash; Function: char * <b>stringprep_convert</b> (<var>const char * str, const char * to_codeset, const char * from_codeset</var>)<var><a name="index-stringprep_005fconvert-57"></a></var><br>
<blockquote><p><var>str</var>: input zero-terminated string.

        <p><var>to_codeset</var>: name of destination character set.

        <p><var>from_codeset</var>: name of origin character set, as used by <code>str</code>.

        <p>Convert the string from one character set to another using the
system's <code>iconv()</code> function.

        <p><strong>Return value:</strong> Returns newly allocated zero-terminated string which
is <code>str</code> transcoded into to_codeset. 
</p></blockquote></div>

<h4 class="subheading">stringprep_locale_to_utf8</h4>

<p><a name="stringprep_005flocale_005fto_005futf8"></a>

<div class="defun">
&mdash; Function: char * <b>stringprep_locale_to_utf8</b> (<var>const char * str</var>)<var><a name="index-stringprep_005flocale_005fto_005futf8-58"></a></var><br>
<blockquote><p><var>str</var>: input zero terminated string.

        <p>Convert string encoded in the locale's character set into UTF-8 by
using <code>stringprep_convert()</code>.

        <p><strong>Return value:</strong> Returns newly allocated zero-terminated string which
is <code>str</code> transcoded into UTF-8. 
</p></blockquote></div>

<h4 class="subheading">stringprep_utf8_to_locale</h4>

<p><a name="stringprep_005futf8_005fto_005flocale"></a>

<div class="defun">
&mdash; Function: char * <b>stringprep_utf8_to_locale</b> (<var>const char * str</var>)<var><a name="index-stringprep_005futf8_005fto_005flocale-59"></a></var><br>
<blockquote><p><var>str</var>: input zero terminated string.

        <p>Convert string encoded in UTF-8 into the locale's character set by
using <code>stringprep_convert()</code>.

        <p><strong>Return value:</strong> Returns newly allocated zero-terminated string which
is <code>str</code> transcoded into the locale's character set. 
</p></blockquote></div>

<!-- ********************************************************** -->
<!-- ******************  Stringprep Functions ***************** -->
<!-- ********************************************************** -->
<div class="node">
<a name="Stringprep-Functions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Punycode-Functions">Punycode Functions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Utility-Functions">Utility Functions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">4 Stringprep Functions</h2>

<p><a name="index-Stringprep-Functions-60"></a>
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.

<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><span class="file">stringprep.h</span></samp> using:

<pre class="example">     #include &lt;stringprep.h&gt;
</pre>
   <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><span class="file">stringprep.h</span></samp> header file, and the
<samp><span class="file">profiles.c</span></samp> source code for the details.

<h3 class="section">4.3 Control Flags</h3>

<div class="defun">
&mdash; Stringprep flags: Stringprep_profile_flags <b>STRINGPREP_NO_NFKC</b><var><a name="index-STRINGPREP_005fNO_005fNFKC-61"></a></var><br>
<blockquote><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></blockquote></div>

<div class="defun">
&mdash; Stringprep flags: Stringprep_profile_flags <b>STRINGPREP_NO_BIDI</b><var><a name="index-STRINGPREP_005fNO_005fBIDI-62"></a></var><br>
<blockquote><p>Disable the BIDI step.  Usually the profile specifies BIDI and NFKC
settings, and applications should not override it unless in special
situations. 
</p></blockquote></div>

<div class="defun">
&mdash; Stringprep flags: Stringprep_profile_flags <b>STRINGPREP_NO_UNASSIGNED</b><var><a name="index-STRINGPREP_005fNO_005fUNASSIGNED-63"></a></var><br>
<blockquote><p>Make the library return with an error if string contains unassigned
characters according to profile. 
</p></blockquote></div>

<h3 class="section">4.4 Core Functions</h3>

<h4 class="subheading">stringprep_4i</h4>

<p><a name="stringprep_005f4i"></a>

<div class="defun">
&mdash; Function: int <b>stringprep_4i</b> (<var>uint32_t * ucs4, size_t * len, size_t maxucs4len, Stringprep_profile_flags flags, const Stringprep_profile * profile</var>)<var><a name="index-stringprep_005f4i-64"></a></var><br>
<blockquote><p><var>ucs4</var>: input/output array with string to prepare.

        <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><var>maxucs4len</var>: maximum length of input/output array.

        <p><var>flags</var>: a <code>Stringprep_profile_flags</code> value, or 0.

        <p><var>profile</var>: pointer to <code>Stringprep_profile</code> to use.

        <p>Prepare the input UCS-4 string according to the stringprep profile,
and write back the result to the input string.

        <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>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>The <code>flags</code> are one of <code>Stringprep_profile_flags</code> values, or 0.

        <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><strong>Return value:</strong> Returns <code>STRINGPREP_OK</code> iff successful, or an
<code>Stringprep_rc</code> error code. 
</p></blockquote></div>

<h4 class="subheading">stringprep_4zi</h4>

<p><a name="stringprep_005f4zi"></a>

<div class="defun">
&mdash; Function: int <b>stringprep_4zi</b> (<var>uint32_t * ucs4, size_t maxucs4len, Stringprep_profile_flags flags, const Stringprep_profile * profile</var>)<var><a name="index-stringprep_005f4zi-65"></a></var><br>
<blockquote><p><var>ucs4</var>: input/output array with zero terminated string to prepare.

        <p><var>maxucs4len</var>: maximum length of input/output array.

        <p><var>flags</var>: a <code>Stringprep_profile_flags</code> value, or 0.

        <p><var>profile</var>: pointer to <code>Stringprep_profile</code> to use.

        <p>Prepare the input zero terminated UCS-4 string according to the
stringprep profile, and write back the result to the input string.

        <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>The <code>flags</code> are one of <code>Stringprep_profile_flags</code> values, or 0.

        <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><strong>Return value:</strong> Returns <code>STRINGPREP_OK</code> iff successful, or an
<code>Stringprep_rc</code> error code. 
</p></blockquote></div>

<h4 class="subheading">stringprep</h4>

<p><a name="stringprep"></a>

<div class="defun">
&mdash; Function: int <b>stringprep</b> (<var>char * in, size_t maxlen, Stringprep_profile_flags flags, const Stringprep_profile * profile</var>)<var><a name="index-stringprep-66"></a></var><br>
<blockquote><p><var>in</var>: input/ouput array with string to prepare.

        <p><var>maxlen</var>: maximum length of input/output array.

        <p><var>flags</var>: a <code>Stringprep_profile_flags</code> value, or 0.

        <p><var>profile</var>: pointer to <code>Stringprep_profile</code> to use.

        <p>Prepare the input zero terminated UTF-8 string according to the
stringprep profile, and write back the result to the input string.

        <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>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>The <code>flags</code> are one of <code>Stringprep_profile_flags</code> values, or 0.

        <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><strong>Return value:</strong> Returns <code>STRINGPREP_OK</code> iff successful, or an error code. 
</p></blockquote></div>

<h4 class="subheading">stringprep_profile</h4>

<p><a name="stringprep_005fprofile"></a>

<div class="defun">
&mdash; Function: int <b>stringprep_profile</b> (<var>const char * in, char ** out, const char * profile, Stringprep_profile_flags flags</var>)<var><a name="index-stringprep_005fprofile-67"></a></var><br>
<blockquote><p><var>in</var>: input array with UTF-8 string to prepare.

        <p><var>out</var>: output variable with pointer to newly allocate string.

        <p><var>profile</var>: name of stringprep profile to use.

        <p><var>flags</var>: a <code>Stringprep_profile_flags</code> value, or 0.

        <p>Prepare the input zero terminated UTF-8 string according to the
stringprep profile, and return the result in a newly allocated
variable.

        <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>The output <code>out</code> variable must be deallocated by the caller.

        <p>The <code>flags</code> are one of <code>Stringprep_profile_flags</code> values, or 0.

        <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><strong>Return value:</strong> Returns <code>STRINGPREP_OK</code> iff successful, or an error code. 
</p></blockquote></div>

<h3 class="section">4.5 Error Handling</h3>

<h4 class="subheading">stringprep_strerror</h4>

<p><a name="stringprep_005fstrerror"></a>

<div class="defun">
&mdash; Function: const char * <b>stringprep_strerror</b> (<var>Stringprep_rc rc</var>)<var><a name="index-stringprep_005fstrerror-68"></a></var><br>
<blockquote><p><var>rc</var>: a <code>Stringprep_rc</code> return code.

        <p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.

        <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><strong>STRINGPREP_CONTAINS_UNASSIGNED:</strong> String contain unassigned Unicode
code points, which is forbidden by the profile.

        <p><strong>STRINGPREP_CONTAINS_PROHIBITED:</strong> String contain code points
prohibited by the profile.

        <p><strong>STRINGPREP_BIDI_BOTH_L_AND_RAL:</strong> String contain code points with
conflicting bidirection category.

        <p><strong>STRINGPREP_BIDI_LEADTRAIL_NOT_RAL:</strong> Leading and trailing character
in string not of proper bidirectional category.

        <p><strong>STRINGPREP_BIDI_CONTAINS_PROHIBITED:</strong> Contains prohibited code
points detected by bidirectional code.

        <p><strong>STRINGPREP_TOO_SMALL_BUFFER:</strong> Buffer handed to function was too
small.  This usually indicate a problem in the calling
application.

        <p><strong>STRINGPREP_PROFILE_ERROR:</strong> The stringprep profile was inconsistent. 
This usually indicate an internal error in the library.

        <p><strong>STRINGPREP_FLAG_ERROR:</strong> The supplied flag conflicted with profile. 
This usually indicate a problem in the calling application.

        <p><strong>STRINGPREP_UNKNOWN_PROFILE:</strong> The supplied profile name was not
known to the library.

        <p><strong>STRINGPREP_NFKC_FAILED:</strong> The Unicode NFKC operation failed.  This
usually indicate an internal error in the library.

        <p><strong>STRINGPREP_MALLOC_ERROR:</strong> The <code>malloc()</code> was out of memory.  This is
usually a fatal error.

        <p><strong>Return value:</strong> Returns a pointer to a statically allocated string
containing a description of the error with the return code <code>rc</code>. 
</p></blockquote></div>

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

<div class="defun">
&mdash; Function: int <b>stringprep_nameprep_no_unassigned</b> (<var>char * in, int maxlen</var>)<var><a name="index-stringprep_005fnameprep_005fno_005funassigned-69"></a></var><br>
<blockquote>
        <p><var>in</var>: input/ouput array with string to prepare.

        <p><var>maxlen</var>: maximum length of input/output array.

        <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></blockquote></div>

<div class="defun">
&mdash; Function: int <b>stringprep_iscsi</b> (<var>char * in, int maxlen</var>)<var><a name="index-stringprep_005fiscsi-70"></a></var><br>
<blockquote>
        <p><var>in</var>: input/ouput array with string to prepare.

        <p><var>maxlen</var>: maximum length of input/output array.

        <p>Prepare the input UTF-8 string according to the draft iSCSI stringprep
profile.  Returns 0 iff successful, or an error code. 
</p></blockquote></div>

<div class="defun">
&mdash; Function: int <b>stringprep_plain</b> (<var>char * in, int maxlen</var>)<var><a name="index-stringprep_005fplain-71"></a></var><br>
<blockquote>
        <p><var>in</var>: input/ouput array with string to prepare.

        <p><var>maxlen</var>: maximum length of input/output array.

        <p>Prepare the input UTF-8 string according to the draft SASL ANONYMOUS
profile.  Returns 0 iff successful, or an error code. 
</p></blockquote></div>

<div class="defun">
&mdash; Function: int <b>stringprep_xmpp_nodeprep</b> (<var>char * in, int maxlen</var>)<var><a name="index-stringprep_005fxmpp_005fnodeprep-72"></a></var><br>
<blockquote>
        <p><var>in</var>: input/ouput array with string to prepare.

        <p><var>maxlen</var>: maximum length of input/output array.

        <p>Prepare the input UTF-8 string according to the draft XMPP node
identifier profile.  Returns 0 iff successful, or an error code. 
</p></blockquote></div>

<div class="defun">
&mdash; Function: int <b>stringprep_xmpp_resourceprep</b> (<var>char * in, int maxlen</var>)<var><a name="index-stringprep_005fxmpp_005fresourceprep-73"></a></var><br>
<blockquote>
        <p><var>in</var>: input/ouput array with string to prepare.

        <p><var>maxlen</var>: maximum length of input/output array.

        <p>Prepare the input UTF-8 string according to the draft XMPP resource
identifier profile.  Returns 0 iff successful, or an error code. 
</p></blockquote></div>

<!-- ********************************************************** -->
<!-- *******************  Punycode Functions ****************** -->
<!-- ********************************************************** -->
<div class="node">
<a name="Punycode-Functions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#IDNA-Functions">IDNA Functions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Stringprep-Functions">Stringprep Functions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">5 Punycode Functions</h2>

<p><a name="index-Punycode-Functions-74"></a>
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.

<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><span class="file">punycode.h</span></samp> using:

<pre class="example">     #include &lt;punycode.h&gt;
</pre>
   <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.

<div class="defun">
&mdash; Punycode Unicode code point: uint32_t <b>punycode_uint</b><var><a name="index-punycode_005fuint-75"></a></var><br>
<blockquote><p>A unsigned integer that hold Unicode code points. 
</p></blockquote></div>

<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>The functions provided are the following two entry points:

<h4 class="subheading">punycode_encode</h4>

<p><a name="punycode_005fencode"></a>

<div class="defun">
&mdash; Function: int <b>punycode_encode</b> (<var>size_t input_length, const punycode_uint </var>[]<var> input, const unsigned char </var>[]<var> case_flags, size_t * output_length, char </var>[]<var> output</var>)<var><a name="index-punycode_005fencode-76"></a></var><br>
<blockquote><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><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><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><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><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>Converts a sequence of code points (presumed to be Unicode code
points) to Punycode.

        <p><strong>Return value:</strong> 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></blockquote></div>

<h4 class="subheading">punycode_decode</h4>

<p><a name="punycode_005fdecode"></a>

<div class="defun">
&mdash; Function: int <b>punycode_decode</b> (<var>size_t input_length, const char </var>[]<var> input, size_t * output_length, punycode_uint </var>[]<var> output, unsigned char </var>[]<var> case_flags</var>)<var><a name="index-punycode_005fdecode-77"></a></var><br>
<blockquote><p><var>input_length</var>: The number of ASCII code points in the <code>input</code> array.

        <p><var>input</var>: An array of ASCII code points (0..7F).

        <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><var>output</var>: An array of code points like the input argument of
<code>punycode_encode()</code> (see above).

        <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>Converts Punycode to a sequence of code points (presumed to be
Unicode code points).

        <p><strong>Return value:</strong> 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></blockquote></div>

<h3 class="section">5.4 Error Handling</h3>

<h4 class="subheading">punycode_strerror</h4>

<p><a name="punycode_005fstrerror"></a>

<div class="defun">
&mdash; Function: const char * <b>punycode_strerror</b> (<var>Punycode_status rc</var>)<var><a name="index-punycode_005fstrerror-78"></a></var><br>
<blockquote><p><var>rc</var>: an <code>Punycode_status</code> return code.

        <p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.

        <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><strong>PUNYCODE_BAD_INPUT:</strong> Input is invalid.

        <p><strong>PUNYCODE_BIG_OUTPUT:</strong> Output would exceed the space provided.

        <p><strong>PUNYCODE_OVERFLOW:</strong> Input needs wider integers to process.

        <p><strong>Return value:</strong> Returns a pointer to a statically allocated string
containing a description of the error with the return code <code>rc</code>. 
</p></blockquote></div>

<!-- ********************************************************** -->
<!-- ********************* IDNA Functions ********************* -->
<!-- ********************************************************** -->
<div class="node">
<a name="IDNA-Functions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#TLD-Functions">TLD Functions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Punycode-Functions">Punycode Functions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">6 IDNA Functions</h2>

<p><a name="index-IDNA-Functions-79"></a>
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.

<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><span class="file">idna.h</span></samp> using:

<pre class="example">     #include &lt;idna.h&gt;
</pre>
   <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:

<div class="defun">
&mdash; Return code: Idna_flags <b>IDNA_ALLOW_UNASSIGNED</b><var><a name="index-IDNA_005fALLOW_005fUNASSIGNED-80"></a></var><br>
<blockquote><p>Allow unassigned Unicode code points. 
</p></blockquote></div>

<div class="defun">
&mdash; Return code: Idna_flags <b>IDNA_USE_STD3_ASCII_RULES</b><var><a name="index-IDNA_005fUSE_005fSTD3_005fASCII_005fRULES-81"></a></var><br>
<blockquote><p>Check output to make sure it is a STD3 conforming host name. 
</p></blockquote></div>

<h3 class="section">6.3 Prefix String</h3>

<div class="defun">
&mdash; Macro: #define <b>IDNA_ACE_PREFIX</b><var><a name="index-IDNA_005fACE_005fPREFIX-82"></a></var><br>
<blockquote><p>String with the official IDNA prefix, <code>xn--</code>. 
</p></blockquote></div>

<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>The functions provided are the following entry points:

<h4 class="subheading">idna_to_ascii_4i</h4>

<p><a name="idna_005fto_005fascii_005f4i"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_ascii_4i</b> (<var>const uint32_t * in, size_t inlen, char * out, int flags</var>)<var><a name="index-idna_005fto_005fascii_005f4i-83"></a></var><br>
<blockquote><p><var>in</var>: input array with unicode code points.

        <p><var>inlen</var>: length of input array with unicode code points.

        <p><var>out</var>: output zero terminated string that must have room for at
least 63 characters plus the terminating zero.

        <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>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>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>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>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><strong>Return value:</strong> Returns 0 on success, or an <code>Idna_rc</code> error code. 
</p></blockquote></div>

<h4 class="subheading">idna_to_unicode_44i</h4>

<p><a name="idna_005fto_005funicode_005f44i"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_unicode_44i</b> (<var>const uint32_t * in, size_t inlen, uint32_t * out, size_t * outlen, int flags</var>)<var><a name="index-idna_005fto_005funicode_005f44i-84"></a></var><br>
<blockquote><p><var>in</var>: input array with unicode code points.

        <p><var>inlen</var>: length of input array with unicode code points.

        <p><var>out</var>: output array with unicode code points.

        <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><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>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>ToUnicode never fails. If any step fails, then the original input
sequence is returned immediately in that step.

        <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>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><strong>Return value:</strong> 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></blockquote></div>

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

<h4 class="subheading">idna_to_ascii_4z</h4>

<p><a name="idna_005fto_005fascii_005f4z"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_ascii_4z</b> (<var>const uint32_t * input, char ** output, int flags</var>)<var><a name="index-idna_005fto_005fascii_005f4z-85"></a></var><br>
<blockquote><p><var>input</var>: zero terminated input Unicode string.

        <p><var>output</var>: pointer to newly allocated output string.

        <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>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><strong>Return value:</strong> Returns <code>IDNA_SUCCESS</code> on success, or error code. 
</p></blockquote></div>

<h4 class="subheading">idna_to_ascii_8z</h4>

<p><a name="idna_005fto_005fascii_005f8z"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_ascii_8z</b> (<var>const char * input, char ** output, int flags</var>)<var><a name="index-idna_005fto_005fascii_005f8z-86"></a></var><br>
<blockquote><p><var>input</var>: zero terminated input UTF-8 string.

        <p><var>output</var>: pointer to newly allocated output string.

        <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>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><strong>Return value:</strong> Returns <code>IDNA_SUCCESS</code> on success, or error code. 
</p></blockquote></div>

<h4 class="subheading">idna_to_ascii_lz</h4>

<p><a name="idna_005fto_005fascii_005flz"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_ascii_lz</b> (<var>const char * input, char ** output, int flags</var>)<var><a name="index-idna_005fto_005fascii_005flz-87"></a></var><br>
<blockquote><p><var>input</var>: zero terminated input string encoded in the current locale's
character set.

        <p><var>output</var>: pointer to newly allocated output string.

        <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>Convert domain name in the locale'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><strong>Return value:</strong> Returns <code>IDNA_SUCCESS</code> on success, or error code. 
</p></blockquote></div>

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

<h4 class="subheading">idna_to_unicode_4z4z</h4>

<p><a name="idna_005fto_005funicode_005f4z4z"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_unicode_4z4z</b> (<var>const uint32_t * input, uint32_t ** output, int flags</var>)<var><a name="index-idna_005fto_005funicode_005f4z4z-88"></a></var><br>
<blockquote><p><var>input</var>: zero-terminated Unicode string.

        <p><var>output</var>: pointer to newly allocated output Unicode string.

        <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>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><strong>Return value:</strong> Returns <code>IDNA_SUCCESS</code> on success, or error code. 
</p></blockquote></div>

<h4 class="subheading">idna_to_unicode_8z4z</h4>

<p><a name="idna_005fto_005funicode_005f8z4z"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_unicode_8z4z</b> (<var>const char * input, uint32_t ** output, int flags</var>)<var><a name="index-idna_005fto_005funicode_005f8z4z-89"></a></var><br>
<blockquote><p><var>input</var>: zero-terminated UTF-8 string.

        <p><var>output</var>: pointer to newly allocated output Unicode string.

        <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>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><strong>Return value:</strong> Returns <code>IDNA_SUCCESS</code> on success, or error code. 
</p></blockquote></div>

<h4 class="subheading">idna_to_unicode_8z8z</h4>

<p><a name="idna_005fto_005funicode_005f8z8z"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_unicode_8z8z</b> (<var>const char * input, char ** output, int flags</var>)<var><a name="index-idna_005fto_005funicode_005f8z8z-90"></a></var><br>
<blockquote><p><var>input</var>: zero-terminated UTF-8 string.

        <p><var>output</var>: pointer to newly allocated output UTF-8 string.

        <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>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><strong>Return value:</strong> Returns <code>IDNA_SUCCESS</code> on success, or error code. 
</p></blockquote></div>

<h4 class="subheading">idna_to_unicode_8zlz</h4>

<p><a name="idna_005fto_005funicode_005f8zlz"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_unicode_8zlz</b> (<var>const char * input, char ** output, int flags</var>)<var><a name="index-idna_005fto_005funicode_005f8zlz-91"></a></var><br>
<blockquote><p><var>input</var>: zero-terminated UTF-8 string.

        <p><var>output</var>: pointer to newly allocated output string encoded in the
current locale's character set.

        <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>Convert possibly ACE encoded domain name in UTF-8 format into a
string encoded in the current locale's character set.  The domain
name may contain several labels, separated by dots.  The output
buffer must be deallocated by the caller.

        <p><strong>Return value:</strong> Returns <code>IDNA_SUCCESS</code> on success, or error code. 
</p></blockquote></div>

<h4 class="subheading">idna_to_unicode_lzlz</h4>

<p><a name="idna_005fto_005funicode_005flzlz"></a>

<div class="defun">
&mdash; Function: int <b>idna_to_unicode_lzlz</b> (<var>const char * input, char ** output, int flags</var>)<var><a name="index-idna_005fto_005funicode_005flzlz-92"></a></var><br>
<blockquote><p><var>input</var>: zero-terminated string encoded in the current locale's
character set.

        <p><var>output</var>: pointer to newly allocated output string encoded in the
current locale's character set.

        <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>Convert possibly ACE encoded domain name in the locale's character
set into a string encoded in the current locale's character set. 
The domain name may contain several labels, separated by dots.  The
output buffer must be deallocated by the caller.

        <p><strong>Return value:</strong> Returns <code>IDNA_SUCCESS</code> on success, or error code. 
</p></blockquote></div>

<h3 class="section">6.7 Error Handling</h3>

<h4 class="subheading">idna_strerror</h4>

<p><a name="idna_005fstrerror"></a>

<div class="defun">
&mdash; Function: const char * <b>idna_strerror</b> (<var>Idna_rc rc</var>)<var><a name="index-idna_005fstrerror-93"></a></var><br>
<blockquote><p><var>rc</var>: an <code>Idna_rc</code> return code.

        <p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.

        <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><strong>IDNA_STRINGPREP_ERROR:</strong> Error during string preparation.

        <p><strong>IDNA_PUNYCODE_ERROR:</strong> Error during punycode operation.

        <p><strong>IDNA_CONTAINS_NON_LDH:</strong> For IDNA_USE_STD3_ASCII_RULES, indicate that
the string contains non-LDH ASCII characters.

        <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><strong>IDNA_INVALID_LENGTH:</strong> The final output string is not within the
(inclusive) range 1 to 63 characters.

        <p><strong>IDNA_NO_ACE_PREFIX:</strong> The string does not contain the ACE prefix
(for ToUnicode).

        <p><strong>IDNA_ROUNDTRIP_VERIFY_ERROR:</strong> The ToASCII operation on output
string does not equal the input.

        <p><strong>IDNA_CONTAINS_ACE_PREFIX:</strong> The input contains the ACE prefix (for
ToASCII).

        <p><strong>IDNA_ICONV_ERROR:</strong> Could not convert string in locale encoding.

        <p><strong>IDNA_MALLOC_ERROR:</strong> Could not allocate buffer (this is typically a
fatal error).

        <p><strong>IDNA_DLOPEN_ERROR:</strong> Could not dlopen the libcidn DSO (only used
internally in libc).

        <p><strong>Return value:</strong> Returns a pointer to a statically allocated string
containing a description of the error with the return code <code>rc</code>. 
</p></blockquote></div>

<!-- ********************************************************** -->
<!-- ********************** TLD Functions ********************* -->
<!-- ********************************************************** -->
<div class="node">
<a name="TLD-Functions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#PR29-Functions">PR29 Functions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#IDNA-Functions">IDNA Functions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">7 TLD Functions</h2>

<p><a name="index-TLD-Functions-94"></a>
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>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>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>.

<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><span class="file">tld.h</span></samp> using:

<pre class="example">     #include &lt;tld.h&gt;
</pre>
   <!-- @section Data Types -->
<!-- @deftp {Data type} {Tld_table_element} @var{start} @var{end} -->
<!-- @example -->
<!-- /* Interval of valid code points in the TLD. */ -->
<!-- struct Tld_table_element -->
<!-- @{ -->
<!-- uint32_t start;		/* Start of range. */ -->
<!-- uint32_t end;		/* End of range, end == start if single. */ -->
<!-- @}; -->
<!-- typedef struct Tld_table_element Tld_table_element; -->
<!-- @end example -->
<!-- This @code{struct} contain the @var{start} and @var{end} positions -->
<!-- (inclusive) of a range.  If the range is a single (i.e., starts and -->
<!-- ends in the same character), then set @var{end} to the same as -->
<!-- @var{start}.  This structure is normally used as an array. -->
<!-- @end deftp -->
<!-- @deftp {Data type} {Tld_table} @var{name} @var{version} @var{nvalid} @var{valid} -->
<!-- @example -->
<!-- /* List valid code points in a TLD. */ -->
<!-- struct Tld_table -->
<!-- @{ -->
<!-- char *name;			/* TLD name, e.g., "no". */ -->
<!-- char *version;		/* Version string from TLD file. */ -->
<!-- size_t nvalid;		/* Number of entries in data. */ -->
<!-- Tld_table_element *valid[];	/* Sorted array of valid code points. */ -->
<!-- @}; -->
<!-- typedef struct Tld_table Tld_table; -->
<!-- @end example -->
<!-- In this @code{struct}, the @var{name} field is a string (@samp{char*}) -->
<!-- indicating the TLD name (e.g., ``no'').  The @var{version} field is a -->
<!-- string (@samp{char*}) containing a free form humanly readable string -->
<!-- that can be used for equality comparison to compare different versions -->
<!-- of the table.  The @var{nvalid} field indicate how many entries there -->
<!-- are in @var{valid}, which brings us finally to @var{valid} that -->
<!-- contain the actual code points that are valid for this TLD (see -->
<!-- @code{Tld_table_element} above). -->
<!-- @end deftp -->
<h3 class="section">7.2 Core Functions</h3>

<h4 class="subheading">tld_check_4t</h4>

<p><a name="tld_005fcheck_005f4t"></a>

<div class="defun">
&mdash; Function: int <b>tld_check_4t</b> (<var>const uint32_t * in, size_t inlen, size_t * errpos, const Tld_table * tld</var>)<var><a name="index-tld_005fcheck_005f4t-95"></a></var><br>
<blockquote><p><var>in</var>: Array of unicode code points to process. Does not need to be
zero terminated.

        <p><var>inlen</var>: Number of unicode code points.

        <p><var>errpos</var>: Position of offending character is returned here.

        <p><var>tld</var>: A <code>Tld_table</code> data structure representing the restrictions for
which the input should be tested.

        <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><strong>Return value:</strong> 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></blockquote></div>

<h4 class="subheading">tld_check_4tz</h4>

<p><a name="tld_005fcheck_005f4tz"></a>

<div class="defun">
&mdash; Function: int <b>tld_check_4tz</b> (<var>const uint32_t * in, size_t * errpos, const Tld_table * tld</var>)<var><a name="index-tld_005fcheck_005f4tz-96"></a></var><br>
<blockquote><p><var>in</var>: Zero terminated array of unicode code points to process.

        <p><var>errpos</var>: Position of offending character is returned here.

        <p><var>tld</var>: A <code>Tld_table</code> data structure representing the restrictions for
which the input should be tested.

        <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><strong>Return value:</strong> 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></blockquote></div>

<h3 class="section">7.3 Utility Functions</h3>

<h4 class="subheading">tld_get_4</h4>

<p><a name="tld_005fget_005f4"></a>

<div class="defun">
&mdash; Function: int <b>tld_get_4</b> (<var>const uint32_t * in, size_t inlen, char ** out</var>)<var><a name="index-tld_005fget_005f4-97"></a></var><br>
<blockquote><p><var>in</var>: Array of unicode code points to process. Does not need to be
zero terminated.

        <p><var>inlen</var>: Number of unicode code points.

        <p><var>out</var>: Zero terminated ascii result string pointer.

        <p>Isolate the top-level domain of <code>in</code> and return it as an ASCII
string in <code>out</code>.

        <p><strong>Return value:</strong> Return <code>TLD_SUCCESS</code> on success, or the corresponding
<code>Tld_rc</code> error code otherwise. 
</p></blockquote></div>

<h4 class="subheading">tld_get_4z</h4>

<p><a name="tld_005fget_005f4z"></a>

<div class="defun">
&mdash; Function: int <b>tld_get_4z</b> (<var>const uint32_t * in, char ** out</var>)<var><a name="index-tld_005fget_005f4z-98"></a></var><br>
<blockquote><p><var>in</var>: Zero terminated array of unicode code points to process.

        <p><var>out</var>: Zero terminated ascii result string pointer.

        <p>Isolate the top-level domain of <code>in</code> and return it as an ASCII
string in <code>out</code>.

        <p><strong>Return value:</strong> Return <code>TLD_SUCCESS</code> on success, or the corresponding
<code>Tld_rc</code> error code otherwise. 
</p></blockquote></div>

<h4 class="subheading">tld_get_z</h4>

<p><a name="tld_005fget_005fz"></a>

<div class="defun">
&mdash; Function: int <b>tld_get_z</b> (<var>const char * in, char ** out</var>)<var><a name="index-tld_005fget_005fz-99"></a></var><br>
<blockquote><p><var>in</var>: Zero terminated character array to process.

        <p><var>out</var>: Zero terminated ascii result string pointer.

        <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><strong>Return value:</strong> Return <code>TLD_SUCCESS</code> on success, or the corresponding
<code>Tld_rc</code> error code otherwise. 
</p></blockquote></div>

<h4 class="subheading">tld_get_table</h4>

<p><a name="tld_005fget_005ftable"></a>

<div class="defun">
&mdash; Function: const Tld_table * <b>tld_get_table</b> (<var>const char * tld, const Tld_table ** tables</var>)<var><a name="index-tld_005fget_005ftable-100"></a></var><br>
<blockquote><p><var>tld</var>: TLD name (e.g. "com") as zero terminated ASCII byte string.

        <p><var>tables</var>: Zero terminated array of <code>Tld_table</code> info-structures for
TLDs.

        <p>Get the TLD table for a named TLD by searching through the given
TLD table array.

        <p><strong>Return value:</strong> 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></blockquote></div>

<h4 class="subheading">tld_default_table</h4>

<p><a name="tld_005fdefault_005ftable"></a>

<div class="defun">
&mdash; Function: const Tld_table * <b>tld_default_table</b> (<var>const char * tld, const Tld_table ** overrides</var>)<var><a name="index-tld_005fdefault_005ftable-101"></a></var><br>
<blockquote><p><var>tld</var>: TLD name (e.g. "com") as zero terminated ASCII byte string.

        <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>Get the TLD table for a named TLD, using the internal defaults,
possibly overrided by the (optional) supplied tables.

        <p><strong>Return value:</strong> 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></blockquote></div>

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

<h4 class="subheading">tld_check_4</h4>

<p><a name="tld_005fcheck_005f4"></a>

<div class="defun">
&mdash; Function: int <b>tld_check_4</b> (<var>const uint32_t * in, size_t inlen, size_t * errpos, const Tld_table ** overrides</var>)<var><a name="index-tld_005fcheck_005f4-102"></a></var><br>
<blockquote><p><var>in</var>: Array of unicode code points to process. Does not need to be
zero terminated.

        <p><var>inlen</var>: Number of unicode code points.

        <p><var>errpos</var>: Position of offending character is returned here.

        <p><var>overrides</var>: A <code>Tld_table</code> array of additional domain restriction
structures that complement and supersede the built-in information.

        <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><strong>Return value:</strong> 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></blockquote></div>

<h4 class="subheading">tld_check_4z</h4>

<p><a name="tld_005fcheck_005f4z"></a>

<div class="defun">
&mdash; Function: int <b>tld_check_4z</b> (<var>const uint32_t * in, size_t * errpos, const Tld_table ** overrides</var>)<var><a name="index-tld_005fcheck_005f4z-103"></a></var><br>
<blockquote><p><var>in</var>: Zero-terminated array of unicode code points to process.

        <p><var>errpos</var>: Position of offending character is returned here.

        <p><var>overrides</var>: A <code>Tld_table</code> array of additional domain restriction
structures that complement and supersede the built-in information.

        <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><strong>Return value:</strong> 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></blockquote></div>

<h4 class="subheading">tld_check_8z</h4>

<p><a name="tld_005fcheck_005f8z"></a>

<div class="defun">
&mdash; Function: int <b>tld_check_8z</b> (<var>const char * in, size_t * errpos, const Tld_table ** overrides</var>)<var><a name="index-tld_005fcheck_005f8z-104"></a></var><br>
<blockquote><p><var>in</var>: Zero-terminated UTF8 string to process.

        <p><var>errpos</var>: Position of offending character is returned here.

        <p><var>overrides</var>: A <code>Tld_table</code> array of additional domain restriction
structures that complement and supersede the built-in information.

        <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><strong>Return value:</strong> 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></blockquote></div>

<h4 class="subheading">tld_check_lz</h4>

<p><a name="tld_005fcheck_005flz"></a>

<div class="defun">
&mdash; Function: int <b>tld_check_lz</b> (<var>const char * in, size_t * errpos, const Tld_table ** overrides</var>)<var><a name="index-tld_005fcheck_005flz-105"></a></var><br>
<blockquote><p><var>in</var>: Zero-terminated string in the current locales encoding to process.

        <p><var>errpos</var>: Position of offending character is returned here.

        <p><var>overrides</var>: A <code>Tld_table</code> array of additional domain restriction
structures that complement and supersede the built-in information.

        <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><strong>Return value:</strong> 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></blockquote></div>

<h3 class="section">7.5 Error Handling</h3>

<h4 class="subheading">tld_strerror</h4>

<p><a name="tld_005fstrerror"></a>

<div class="defun">
&mdash; Function: const char * <b>tld_strerror</b> (<var>Tld_rc rc</var>)<var><a name="index-tld_005fstrerror-106"></a></var><br>
<blockquote><p><var>rc</var>: tld return code

        <p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.

        <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><strong>TLD_INVALID:</strong> Invalid character found.

        <p><strong>TLD_NODATA:</strong> No input data was provided.

        <p><strong>TLD_MALLOC_ERROR:</strong> Error during memory allocation.

        <p><strong>TLD_ICONV_ERROR:</strong> Error during iconv string conversion.

        <p><strong>TLD_NO_TLD:</strong> No top-level domain found in domain string.

        <p><strong>Return value:</strong> Returns a pointer to a statically allocated string
containing a description of the error with the return code <code>rc</code>. 
</p></blockquote></div>

<!-- ********************************************************** -->
<!-- ********************** PR29 Functions ******************** -->
<!-- ********************************************************** -->
<div class="node">
<a name="PR29-Functions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Examples">Examples</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#TLD-Functions">TLD Functions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">8 PR29 Functions</h2>

<p><a name="index-PR29-Functions-107"></a>
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>A full discussion of the problem may be found at:

   <p><a href="http://www.unicode.org/review/pr-29.html">http://www.unicode.org/review/pr-29.html</a>

   <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>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>.

<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><span class="file">pr29.h</span></samp> using:

<pre class="example">     #include &lt;pr29.h&gt;
</pre>
   <h3 class="section">8.2 Core Functions</h3>

<h4 class="subheading">pr29_4</h4>

<p><a name="pr29_005f4"></a>

<div class="defun">
&mdash; Function: int <b>pr29_4</b> (<var>const uint32_t * in, size_t len</var>)<var><a name="index-pr29_005f4-108"></a></var><br>
<blockquote><p><var>in</var>: input array with unicode code points.

        <p><var>len</var>: length of input array with unicode code points.

        <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><strong>Return value:</strong> Returns the <code>Pr29_rc</code> value <code>PR29_SUCCESS</code> on success,
and <code>PR29_PROBLEM</code> if the input sequence is a "problem sequence"
(i.e., may be normalized into different strings by different
implementations). 
</p></blockquote></div>

<h3 class="section">8.3 Utility Functions</h3>

<h4 class="subheading">pr29_4z</h4>

<p><a name="pr29_005f4z"></a>

<div class="defun">
&mdash; Function: int <b>pr29_4z</b> (<var>const uint32_t * in</var>)<var><a name="index-pr29_005f4z-109"></a></var><br>
<blockquote><p><var>in</var>: zero terminated array of Unicode code points.

        <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><strong>Return value:</strong> Returns the <code>Pr29_rc</code> value <code>PR29_SUCCESS</code> on success,
and <code>PR29_PROBLEM</code> if the input sequence is a "problem sequence"
(i.e., may be normalized into different strings by different
implementations). 
</p></blockquote></div>

<h4 class="subheading">pr29_8z</h4>

<p><a name="pr29_005f8z"></a>

<div class="defun">
&mdash; Function: int <b>pr29_8z</b> (<var>const char * in</var>)<var><a name="index-pr29_005f8z-110"></a></var><br>
<blockquote><p><var>in</var>: zero terminated input UTF-8 string.

        <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><strong>Return value:</strong> Returns the <code>Pr29_rc</code> value <code>PR29_SUCCESS</code> on success,
and <code>PR29_PROBLEM</code> if the input sequence is a "problem sequence"
(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></blockquote></div>

<h3 class="section">8.4 Error Handling</h3>

<h4 class="subheading">pr29_strerror</h4>

<p><a name="pr29_005fstrerror"></a>

<div class="defun">
&mdash; Function: const char * <b>pr29_strerror</b> (<var>Pr29_rc rc</var>)<var><a name="index-pr29_005fstrerror-111"></a></var><br>
<blockquote><p><var>rc</var>: an <code>Pr29_rc</code> return code.

        <p>Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.

        <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><strong>PR29_PROBLEM:</strong> A problem sequence was encountered.

        <p><strong>PR29_STRINGPREP_ERROR:</strong> The character set conversion failed (only
for <code>pr29_8z()</code>).

        <p><strong>Return value:</strong> Returns a pointer to a statically allocated string
containing a description of the error with the return code <code>rc</code>. 
</p></blockquote></div>

<!-- ********************************************************** -->
<!-- ***********************  Examples  *********************** -->
<!-- ********************************************************** -->
<div class="node">
<a name="Examples"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Invoking-idn">Invoking idn</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#PR29-Functions">PR29 Functions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">9 Examples</h2>

<p><a name="index-Examples-112"></a>
This chapter contains example code which illustrate how `Libidn' can
be used when writing your own application.

<ul class="menu">
<li><a accesskey="1" href="#Example-1">Example 1</a>: 		Example using stringprep. 
<li><a accesskey="2" href="#Example-2">Example 2</a>: 		Example using punycode. 
<li><a accesskey="3" href="#Example-3">Example 3</a>: 		Example using IDNA ToASCII. 
<li><a accesskey="4" href="#Example-4">Example 4</a>: 		Example using IDNA ToUnicode. 
<li><a accesskey="5" href="#Example-5">Example 5</a>: 		Example using TLD checking. 
</ul>

<div class="node">
<a name="Example-1"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Example-2">Example 2</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<h3 class="section">9.1 Example 1</h3>

<p>This example demonstrates how the stringprep functions are used.

<pre class="verbatim">/* example.c --- Example code showing how to use stringprep().
 * Copyright (C) 2002-2013 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/>.
 *
 */

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

/*
 * 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, "");

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

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

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

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

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

  return 0;
}
</pre>
<div class="node">
<a name="Example-2"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Example-3">Example 3</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Example-1">Example 1</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<h3 class="section">9.2 Example 2</h3>

<p>This example demonstrates how the punycode functions are used.

<pre class="verbatim">/* example2.c --- Example code showing how to use punycode.
 * Copyright (C) 2002-2013 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/>.
 *
 */

#include &lt;locale.h>		/* 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>
#include &lt;stdio.h>
#include &lt;stdlib.h>
#include &lt;string.h>

#include &lt;punycode.h>

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

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

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

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

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

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, "");

  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 ("%2s%lx", uplus, &amp;codept);
	  if (ferror (stdin))
	    fail (io_error);
	  if (r == EOF || r == 0)
	    break;

	  if (r != 2 || uplus[1] != '+' || codept > (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 >= 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 ("%s+%04lX\n",
		      case_flags[j] ? "U" : "u", (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>
<div class="node">
<a name="Example-3"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Example-4">Example 4</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Example-2">Example 2</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<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.

<pre class="verbatim">/* example3.c --- Example ToASCII() code showing how to use Libidn.
 * Copyright (C) 2002-2013 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/>.
 *
 */

#include &lt;stdio.h>
#include &lt;stdlib.h>
#include &lt;string.h>
#include &lt;locale.h>		/* setlocale() */
#include &lt;stringprep.h>		/* stringprep_locale_charset() */
#include &lt;idna.h>		/* 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, "");

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

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

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

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

  free (p);

  return 0;
}
</pre>
<div class="node">
<a name="Example-4"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Example-5">Example 5</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Example-3">Example 3</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<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.

<pre class="verbatim">/* example4.c --- Example ToUnicode() code showing how to use Libidn.
 * Copyright (C) 2002-2013 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/>.
 *
 */

#include &lt;stdio.h>
#include &lt;stdlib.h>
#include &lt;string.h>
#include &lt;locale.h>		/* setlocale() */
#include &lt;stringprep.h>		/* stringprep_locale_charset() */
#include &lt;idna.h>		/* 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, "");

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

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

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

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

  free (p);

  return 0;
}
</pre>
<div class="node">
<a name="Example-5"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Example-4">Example 4</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<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.

<pre class="verbatim">/* example5.c --- Example TLD checking.
 * Copyright (C) 2004-2013 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/>.
 *
 */

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

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

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

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

/*
 * 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 ("Input domain encoded as `%s': ", stringprep_locale_charset ());
  fflush (stdout);
  if (!fgets (buf, BUFSIZ, stdin))
    perror ("fgets");
  buf[strlen (buf) - 1] = '\0';

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

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

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

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

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

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

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

  printf ("Domain accepted by TLD check\n");

  return 0;
}
</pre>
<!-- ********************************************************** -->
<!-- *********************  Invoking idn  ********************* -->
<!-- ********************************************************** -->
<div class="node">
<a name="Invoking-idn"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Emacs-API">Emacs API</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Examples">Examples</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">10 Invoking idn</h2>

<p><a name="index-idn-113"></a><a name="index-invoking-_0040command_007bidn_007d-114"></a><a name="index-command-line-115"></a>

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

<p>GNU Libidn (idn) &ndash; Internationalized Domain Names command line tool

<h3 class="section">10.2 Description</h3>

<p><code>idn</code> allows internationalized string preparation
(&lsquo;<samp><span class="samp">stringprep</span></samp>&rsquo;), encoding and decoding of punycode data, and IDNA
ToASCII/ToUnicode operations to be performed on the command line.

   <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>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>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>.

<h3 class="section">10.3 Options</h3>

<p><code>idn</code> recognizes these commands:

<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>

<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:

<pre class="example">     $ CHARSET=ISO-8859-1 idn --punycode-encode
     ...
</pre>
   <h3 class="section">10.5 Examples</h3>

<p>Standard usage, reading input from standard input:

<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>
   <p>Reading input from command line, and disable printing copyright and
license information:

<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>
   <p>Accessing a specific StringPrep profile directly:

<pre class="example">     jas@latte:~$ idn --quiet --profile=SASLprep --stringprep te&szlig;t&ordf;
     te&szlig;ta
     jas@latte:~$
</pre>
   <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>The first step to troubleshooting character encoding problems with
Libidn is to use the &lsquo;<samp><span class="samp">--debug</span></samp>&rsquo; parameter to find out which
character set encoding &lsquo;<samp><span class="samp">idn</span></samp>&rsquo; believe your locale uses.

<pre class="example">     jas@latte:~$ idn --debug --quiet ""
     system locale uses charset `UTF-8'.
     
     jas@latte:~$
</pre>
   <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><span class="samp">LANG=sv_SE.UTF-8; export
LANG</span></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>Sometimes &lsquo;<samp><span class="samp">idn</span></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:

<pre class="example">     jas@latte:~$ idn --quiet foo
     idn: could not convert from ISO-8859-1 to UTF-8.
     jas@latte:~$
</pre>
   <p>The simplest explanation is that you haven't installed the
&lsquo;<samp><span class="samp">iconv</span></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><span class="samp">glibc-locale</span></samp>&rsquo; for Debian) to
be able to use it.

   <p>Another explanation is that the error is correct and you are feeding
&lsquo;<samp><span class="samp">idn</span></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><span class="samp">idn</span></samp>&rsquo; with the &lsquo;<samp><span class="samp">CHARSET</span></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'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.

<pre class="example">     jas@latte:~$ idn --quiet --debug ""
     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>
   <p>The sense moral here is to forget about &lsquo;<samp><span class="samp">CHARSET</span></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><span class="samp">--debug</span></samp>&rsquo; that you get the desired results.

<div class="node">
<a name="Emacs-API"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Java-API">Java API</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Invoking-idn">Invoking idn</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">11 Emacs API</h2>

<p>Included in Libidn are <samp><span class="file">punycode.el</span></samp> and <samp><span class="file">idna.el</span></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.

<h3 class="section">11.1 Punycode Emacs API</h3>

<div class="defun">
&mdash; Variable: <b>punycode-program</b><var><a name="index-punycode_002dprogram-116"></a></var><br>
<blockquote><p>Name of the GNU Libidn <samp><span class="file">idn</span></samp> application.  The default is
&lsquo;<samp><span class="samp">idn</span></samp>&rsquo;.  This variable can be customized. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>punycode-environment</b><var><a name="index-punycode_002denvironment-117"></a></var><br>
<blockquote><p>List of environment variable definitions prepended to
&lsquo;<samp><span class="samp">process-environment</span></samp>&rsquo;.  The default is &lsquo;<samp><span class="samp">("CHARSET=UTF-8")</span></samp>&rsquo;. 
This variable can be customized. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>punycode-encode-parameters</b><var><a name="index-punycode_002dencode_002dparameters-118"></a></var><br>
<blockquote><p>List of parameters passed to <var>punycode-program</var> to invoke punycode
encoding mode.  The default is &lsquo;<samp><span class="samp">("--quiet" "--punycode-encode")</span></samp>&rsquo;. 
This variable can be customized. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>punycode-decode-parameters</b><var><a name="index-punycode_002ddecode_002dparameters-119"></a></var><br>
<blockquote><p>Parameters passed to <var>punycode-program</var> to invoke punycode
decoding mode.  The default is &lsquo;<samp><span class="samp">("--quiet" "--punycode-decode")</span></samp>&rsquo;. 
This variable can be customized. 
</p></blockquote></div>

<div class="defun">
&mdash; Function: <b>punycode-encode</b><var> string<a name="index-punycode_002dencode-120"></a></var><br>
<blockquote><p>Returns a Punycode encoding of the <var>string</var>, after converting the
input into UTF-8. 
</p></blockquote></div>

<div class="defun">
&mdash; Function: <b>punycode-decode</b><var> string<a name="index-punycode_002ddecode-121"></a></var><br>
<blockquote><p>Returns a possibly multibyte string which is the decoding of the
<var>string</var> which is a punycode encoded string. 
</p></blockquote></div>

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

<div class="defun">
&mdash; Variable: <b>idna-program</b><var><a name="index-idna_002dprogram-122"></a></var><br>
<blockquote><p>Name of the GNU Libidn <samp><span class="file">idn</span></samp> application.  The default is
&lsquo;<samp><span class="samp">idn</span></samp>&rsquo;.  This variable can be customized. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>idna-environment</b><var><a name="index-idna_002denvironment-123"></a></var><br>
<blockquote><p>List of environment variable definitions prepended to
&lsquo;<samp><span class="samp">process-environment</span></samp>&rsquo;.  The default is &lsquo;<samp><span class="samp">("CHARSET=UTF-8")</span></samp>&rsquo;. 
This variable can be customized. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>idna-to-ascii-parameters</b><var><a name="index-idna_002dto_002dascii_002dparameters-124"></a></var><br>
<blockquote><p>List of parameters passed to <var>idna-program</var> to invoke IDNA ToASCII
mode.  The default is &lsquo;<samp><span class="samp">("--quiet" "--idna-to-ascii"
"--usestd3asciirules")</span></samp>&rsquo;.  This variable can be customized. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>idna-to-unicode-parameters</b><var><a name="index-idna_002dto_002dunicode_002dparameters-125"></a></var><br>
<blockquote><p>Parameters passed <var>idna-program</var> to invoke IDNA ToUnicode mode. 
The default is &lsquo;<samp><span class="samp">("--quiet" "--idna-to-unicode"
"--usestd3asciirules")</span></samp>&rsquo;.  This variable can be customized. 
</p></blockquote></div>

<div class="defun">
&mdash; Function: <b>idna-to-ascii</b><var> string<a name="index-idna_002dto_002dascii-126"></a></var><br>
<blockquote><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></blockquote></div>

<div class="defun">
&mdash; Function: <b>idna-to-unicode</b><var> string<a name="index-idna_002dto_002dunicode-127"></a></var><br>
<blockquote><p>Returns a possibly multibyte string which is the output of the IDNA
ToUnicode operation computed on the input <var>string</var>. 
</p></blockquote></div>

<div class="node">
<a name="Java-API"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#C_0023-API">C# API</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Emacs-API">Emacs API</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<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>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><span class="file">java/libidn-1.28.jar</span></samp>.  The source code is below
<samp><span class="file">java/</span></samp> in Maven directory layout, and there is a Maven
<samp><span class="file">pom.xml</span></samp> build script as well.  Source code files are in
<samp><span class="file">java/src/main/java/gnu/inet/encoding/</span></samp>.

<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>The gnu.inet.encoding.IDNA class offers two public functions, toASCII
and toUnicode which can be used as follows:

<pre class="example">     gnu.inet.encoding.IDNA.toASCII("bl&ouml;ds.z&uuml;g");
     gnu.inet.encoding.IDNA.toUnicode("xn--blds-6qa.xn--zg-xka");
</pre>
   <h3 class="section">12.2 Miscellaneous Programs</h3>

<p>The <samp><span class="file">java/src/util/java/</span></samp> directory contains several programs that
are related to the Java part of GNU Libidn, but that don't need to be
included in the main source tree or the JAR file.

<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>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>Invoke the program as follows:

<pre class="example">     $ java GenerateRFC3454
     Creating RFC3454.java... Ok.
</pre>
   <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>The Unicode data files can be found at
<a href="http://www.unicode.org/Public/">http://www.unicode.org/Public/</a>.

   <p>Invoke the program as follows:

<pre class="example">     $ java GenerateNFKC
     Creating CombiningClass.java... Ok.
     Creating DecompositionKeys.java... Ok.
     Creating DecompositionMappings.java... Ok.
     Creating Composition.java... Ok.
</pre>
   <h4 class="subsection">12.2.3 TestIDNA</h4>

<p>The TestIDNA program allows to test the IDNA implementation manually
or against Simon Josefsson's test vectors.

   <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>To test the transformation manually, use:

<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>
   <p>To test against draft-josefsson-idn-test-vectors.html, use:

<pre class="example">     $ java -cp .:/usr/share/java/libidn/libidn.jar TestIDNA -t
     No errors detected!
</pre>
   <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>To test the normalization manually, use:

<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>
   <p>To test against NormalizationTest.txt:

<pre class="example">     $ java -cp .:/usr/share/java/libidn.jar TestNFKC
     No errors detected!
</pre>
   <h3 class="section">12.3 Possible Problems</h3>

<p>Beware of Bugs: This Java API needs a lot more testing, especially
with "exotic" character sets. While it works for me, it may not work
for you.

   <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>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.

<h3 class="section">12.4 A Note on Java and Unicode</h3>

<p>This library uses Java's built-in 'char' 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't work
for Supplementary Characters (i.e. characters from U+10000 to
U+10FFFF). All references to such characters are silently ignored.

   <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>For more information refer to the documentation of java.lang.Character
in the JDK API.

<div class="node">
<a name="C%23-API"></a>
<a name="C_0023-API"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Acknowledgements">Acknowledgements</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Java-API">Java API</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<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><span class="file">csharp/</span></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.

<!-- ********************************************************** -->
<!-- *******************  Acknowledgements  ******************* -->
<!-- ********************************************************** -->
<div class="node">
<a name="Acknowledgements"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#History">History</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#C_0023-API">C# API</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<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>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>Several people reported bugs, sent patches or suggested improvements,
see the file THANKS in the top-level directory of the source code.

<!-- ********************************************************** -->
<!-- ************************  History  *********************** -->
<!-- ********************************************************** -->
<div class="node">
<a name="History"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#PR29-discussion">PR29 discussion</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Acknowledgements">Acknowledgements</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">15 History</h2>

<p>The complete history of user visible changes is stored in the file
<samp><span class="file">NEWS</span></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><span class="file">ChangeLog</span></samp> in the same directory.  This section contain a
condensed version of that information, in the form of &ldquo;milestones&rdquo;
for the project.

     <dl>
<dt>Stringprep implementation.<dd>Version 0.0.0 released on 2002-11-05.

     <br><dt>IDNA and Punycode implementations, part of the GNU project.<dd>Version 0.1.0 released on 2003-01-05.

     <br><dt>Uses official IDNA ACE prefix <code>xn--</code>.<dd>Version 0.1.7 released on 2003-02-12.

     <br><dt>Command line interface.<dd>Version 0.1.11 released on 2003-02-26.

     <br><dt>GNU Libc add-on proposed.<dd>Version 0.1.12 released on 2003-03-06.

     <br><dt>Interoperability testing during IDNConnect.<dd>Version 0.3.1 released on 2003-10-02.

     <br><dt>TLD restriction testing.<dd>Version 0.4.0 released on 2004-02-28.

     <br><dt>GNU Libc add-on integrated.<dd>Version 0.4.1 released on 2004-03-08.

     <br><dt>Native Java implementation.<dd>Version 0.4.2-0.4.9 released between 2004-03-20 and 2004-06-11.

     <br><dt>PR-29 functions for &ldquo;problem sequences&rdquo;.<dd>Version 0.5.0 released on 2004-06-26.

     <br><dt>Many small portability fixes and wider use.<dd>Version 0.5.1 through 0.5.20, released between 2004-07-09 and
2005-10-23.

     <br><dt>Native C# implementation.<dd>Version 0.6.0 released on 2005-12-03.

     <br><dt>Windows support through cross-compilation.<dd>Version 0.6.1 released on 2006-01-20.

     <br><dt>Library declared stable by releasing v1.0.<dd>Version 1.0 released on 2007-07-31.

   </dl>

<div class="node">
<a name="PR29-discussion"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#On-Label-Separators">On Label Separators</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#History">History</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<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'm including my response to the report
as well.

<pre class="verbatim">From: Rick McGowan &lt;rick@unicode.org>
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 > 0 &amp;&amp; (last_cc == 0 || last_cc != cc)) {

should perhaps be changed to:

      if (i > 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 > 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 > 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 > or &lt;=?) here.

In the text of PR29, I will be marking Libidn as "needs change" 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>
Subject: Re: Possible bug and status of PR 29 change(s)
To: Rick McGowan &lt;rick@unicode.org>
Cc: bug-libidn@gnu.org
Date: Thu, 28 Oct 2004 09:47:47 +0200

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

> 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.

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>

<div class="node">
<a name="On-Label-Separators"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Copying-Information">Copying Information</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#PR29-discussion">PR29 discussion</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<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:

<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>
   <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>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>Some implementations <a rel="footnote" href="#fn-1" name="fnd-1"><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:

<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>
   <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.

<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>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.

<div class="node">
<a name="Copying-Information"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Function-and-Variable-Index">Function and Variable Index</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#On-Label-Separators">On Label Separators</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="appendix">Appendix C Copying Information</h2>

<ul class="menu">
<li><a accesskey="1" href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>:    License for copying this manual. 
</ul>

<div class="node">
<a name="GNU-Free-Documentation-License"></a>
<p><hr>
Up:&nbsp;<a rel="up" accesskey="u" href="#Copying-Information">Copying Information</a>

</div>

<h3 class="appendixsec">C.1 GNU Free Documentation License</h3>

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

<!-- The GNU Free Documentation License. -->
<div align="center">Version 1.3, 3 November 2008</div>

<!-- This file is intended to be included within another document, -->
<!-- hence no sectioning command or @node. -->
<pre class="display">     Copyright &copy; 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
     <a href="http://fsf.org/">http://fsf.org/</a>
     
     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.
</pre>
     <ol type=1 start=0>
<li>PREAMBLE

     <p>The purpose of this License is to make a manual, textbook, or other
functional and useful document <dfn>free</dfn> 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>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>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.

     <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>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>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'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>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>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>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>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>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's title,
preceding the beginning of the body of the text.

     <p>The &ldquo;publisher&rdquo; means any person or entity that distributes copies
of the Document to the public.

     <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>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.

     <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>You may also lend copies, under the same conditions stated above, and
you may publicly display copies.

     <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'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>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>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>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.

     <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:

          <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>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>State on the Title page the name of the publisher of the
Modified Version, as the publisher.

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

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

          <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>Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.

          <li>Include an unaltered copy of this License.

          <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>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>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>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>Delete any section Entitled &ldquo;Endorsements&rdquo;.  Such a section
may not be included in the Modified Version.

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

          <li>Preserve any Warranty Disclaimers.
          </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's license notice. 
These titles must be distinct from any other section titles.

     <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>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>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.

     <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>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>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;

     <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>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.

     <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'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>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'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.

     <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>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.

     <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>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>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>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.

     <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="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.

     <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's public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.

     <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>&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>&ldquo;Incorporate&rdquo; means to publish or republish a Document, in whole or
in part, as part of another Document.

     <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>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.

        </ol>

<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:

<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>
   <p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the &ldquo;with<small class="dots">...</small>Texts.&rdquo; line with this:

<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>
   <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>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.

<!-- Local Variables: -->
<!-- ispell-local-pdict: "ispell-dict" -->
<!-- End: -->
<div class="node">
<a name="Function-and-Variable-Index"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Concept-Index">Concept Index</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Copying-Information">Copying Information</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="unnumbered">Function and Variable Index</h2>

<ul class="index-fn" compact>
<li><a href="#index-idn_005ffree-48"><code>idn_free</code></a>: <a href="#Memory-handling-under-Windows">Memory handling under Windows</a></li>
<li><a href="#index-idna_002dto_002dascii-126"><code>idna-to-ascii</code></a>: <a href="#Emacs-API">Emacs API</a></li>
<li><a href="#index-idna_002dto_002dunicode-127"><code>idna-to-unicode</code></a>: <a href="#Emacs-API">Emacs API</a></li>
<li><a href="#index-idna_005fstrerror-93"><code>idna_strerror</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005fascii_005f4i-83"><code>idna_to_ascii_4i</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005fascii_005f4z-85"><code>idna_to_ascii_4z</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005fascii_005f8z-86"><code>idna_to_ascii_8z</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005fascii_005flz-87"><code>idna_to_ascii_lz</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005funicode_005f44i-84"><code>idna_to_unicode_44i</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005funicode_005f4z4z-88"><code>idna_to_unicode_4z4z</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005funicode_005f8z4z-89"><code>idna_to_unicode_8z4z</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005funicode_005f8z8z-90"><code>idna_to_unicode_8z8z</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005funicode_005f8zlz-91"><code>idna_to_unicode_8zlz</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-idna_005fto_005funicode_005flzlz-92"><code>idna_to_unicode_lzlz</code></a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-pr29_005f4-108"><code>pr29_4</code></a>: <a href="#PR29-Functions">PR29 Functions</a></li>
<li><a href="#index-pr29_005f4z-109"><code>pr29_4z</code></a>: <a href="#PR29-Functions">PR29 Functions</a></li>
<li><a href="#index-pr29_005f8z-110"><code>pr29_8z</code></a>: <a href="#PR29-Functions">PR29 Functions</a></li>
<li><a href="#index-pr29_005fstrerror-111"><code>pr29_strerror</code></a>: <a href="#PR29-Functions">PR29 Functions</a></li>
<li><a href="#index-punycode_002ddecode-121"><code>punycode-decode</code></a>: <a href="#Emacs-API">Emacs API</a></li>
<li><a href="#index-punycode_002dencode-120"><code>punycode-encode</code></a>: <a href="#Emacs-API">Emacs API</a></li>
<li><a href="#index-punycode_005fdecode-77"><code>punycode_decode</code></a>: <a href="#Punycode-Functions">Punycode Functions</a></li>
<li><a href="#index-punycode_005fencode-76"><code>punycode_encode</code></a>: <a href="#Punycode-Functions">Punycode Functions</a></li>
<li><a href="#index-punycode_005fstrerror-78"><code>punycode_strerror</code></a>: <a href="#Punycode-Functions">Punycode Functions</a></li>
<li><a href="#index-stringprep-66"><code>stringprep</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-stringprep_005f4i-64"><code>stringprep_4i</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-stringprep_005f4zi-65"><code>stringprep_4zi</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-stringprep_005fcheck_005fversion-40"><code>stringprep_check_version</code></a>: <a href="#Version-Check">Version Check</a></li>
<li><a href="#index-stringprep_005fconvert-57"><code>stringprep_convert</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005fiscsi-70"><code>stringprep_iscsi</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-stringprep_005flocale_005fcharset-56"><code>stringprep_locale_charset</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005flocale_005fto_005futf8-58"><code>stringprep_locale_to_utf8</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005fnameprep_005fno_005funassigned-69"><code>stringprep_nameprep_no_unassigned</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-stringprep_005fplain-71"><code>stringprep_plain</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-stringprep_005fprofile-67"><code>stringprep_profile</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-stringprep_005fstrerror-68"><code>stringprep_strerror</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-stringprep_005fucs4_005fnfkc_005fnormalize-54"><code>stringprep_ucs4_nfkc_normalize</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005fucs4_005fto_005futf8-52"><code>stringprep_ucs4_to_utf8</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005funichar_005fto_005futf8-50"><code>stringprep_unichar_to_utf8</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005futf8_005fnfkc_005fnormalize-55"><code>stringprep_utf8_nfkc_normalize</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005futf8_005fto_005flocale-59"><code>stringprep_utf8_to_locale</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005futf8_005fto_005fucs4-53"><code>stringprep_utf8_to_ucs4</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005futf8_005fto_005funichar-51"><code>stringprep_utf8_to_unichar</code></a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-stringprep_005fxmpp_005fnodeprep-72"><code>stringprep_xmpp_nodeprep</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-stringprep_005fxmpp_005fresourceprep-73"><code>stringprep_xmpp_resourceprep</code></a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-tld_005fcheck_005f4-102"><code>tld_check_4</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fcheck_005f4t-95"><code>tld_check_4t</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fcheck_005f4tz-96"><code>tld_check_4tz</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fcheck_005f4z-103"><code>tld_check_4z</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fcheck_005f8z-104"><code>tld_check_8z</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fcheck_005flz-105"><code>tld_check_lz</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fdefault_005ftable-101"><code>tld_default_table</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fget_005f4-97"><code>tld_get_4</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fget_005f4z-98"><code>tld_get_4z</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fget_005ftable-100"><code>tld_get_table</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fget_005fz-99"><code>tld_get_z</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-tld_005fstrerror-106"><code>tld_strerror</code></a>: <a href="#TLD-Functions">TLD Functions</a></li>
   </ul><div class="node">
<a name="Concept-Index"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Function-and-Variable-Index">Function and Variable Index</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="unnumbered">Concept Index</h2>



<ul class="index-cp" compact>
<li><a href="#index-AIX-15">AIX</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-ARM-29">ARM</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-Autoconf-tests-42">Autoconf tests</a>: <a href="#Autoconf-tests">Autoconf tests</a></li>
<li><a href="#index-command-line-115">command line</a>: <a href="#Invoking-idn">Invoking idn</a></li>
<li><a href="#index-Compiling-your-application-41">Compiling your application</a>: <a href="#Building-the-source">Building the source</a></li>
<li><a href="#index-Configure-tests-43">Configure tests</a>: <a href="#Autoconf-tests">Autoconf tests</a></li>
<li><a href="#index-Contributing-38">Contributing</a>: <a href="#Contributing">Contributing</a></li>
<li><a href="#index-de_002dallocation-46">de-allocation</a>: <a href="#Memory-handling-under-Windows">Memory handling under Windows</a></li>
<li><a href="#index-Debian-1">Debian</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-Download-36">Download</a>: <a href="#Downloading-and-Installing">Downloading and Installing</a></li>
<li><a href="#index-Examples-112">Examples</a>: <a href="#Examples">Examples</a></li>
<li><a href="#index-FDL_002c-GNU-Free-Documentation-License-128">FDL, GNU Free Documentation License</a>: <a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a></li>
<li><a href="#index-free-44">free</a>: <a href="#Memory-handling-under-Windows">Memory handling under Windows</a></li>
<li><a href="#index-FreeBSD-23">FreeBSD</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-Hacking-39">Hacking</a>: <a href="#Contributing">Contributing</a></li>
<li><a href="#index-heap-memory-47">heap memory</a>: <a href="#Memory-handling-under-Windows">Memory handling under Windows</a></li>
<li><a href="#index-HP_002dUX-17">HP-UX</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-IBM-34">IBM</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-idn-113"><code>idn</code></a>: <a href="#Invoking-idn">Invoking idn</a></li>
<li><a href="#index-IDNA-Functions-79">IDNA Functions</a>: <a href="#IDNA-Functions">IDNA Functions</a></li>
<li><a href="#index-Installation-35">Installation</a>: <a href="#Downloading-and-Installing">Downloading and Installing</a></li>
<li><a href="#index-invoking-_0040command_007bidn_007d-114">invoking <samp><span class="command">idn</span></samp></a>: <a href="#Invoking-idn">Invoking idn</a></li>
<li><a href="#index-IRIX-14">IRIX</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-MacOS-X-24">MacOS X</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-Mandrake-13">Mandrake</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-Memory-handling-45">Memory handling</a>: <a href="#Memory-handling-under-Windows">Memory handling under Windows</a></li>
<li><a href="#index-Microsoft-31">Microsoft</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-mingw32-32">mingw32</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-Motorola-Coldfire-26">Motorola Coldfire</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-NetBSD-21">NetBSD</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-OpenBSD-22">OpenBSD</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-OpenPower-720-8">OpenPower 720</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-OS_002f2-33">OS/2</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-PR29-Functions-107">PR29 Functions</a>: <a href="#PR29-Functions">PR29 Functions</a></li>
<li><a href="#index-Punycode-Functions-74">Punycode Functions</a>: <a href="#Punycode-Functions">Punycode Functions</a></li>
<li><a href="#index-RedHat-9">RedHat</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-RedHat-Advanced-Server-11">RedHat Advanced Server</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-Reporting-Bugs-37">Reporting Bugs</a>: <a href="#Bug-Reports">Bug Reports</a></li>
<li><a href="#index-Solaris-18">Solaris</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-Stringprep-Functions-60">Stringprep Functions</a>: <a href="#Stringprep-Functions">Stringprep Functions</a></li>
<li><a href="#index-SuSE-4">SuSE</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-SuSE-Linux-5">SuSE Linux</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-TLD-Functions-94">TLD Functions</a>: <a href="#TLD-Functions">TLD Functions</a></li>
<li><a href="#index-Tru64-3">Tru64</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-uClibc-28">uClibc</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-uClinux-27">uClinux</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
<li><a href="#index-Utility-Functions-49">Utility Functions</a>: <a href="#Utility-Functions">Utility Functions</a></li>
<li><a href="#index-Windows-16">Windows</a>: <a href="#Supported-Platforms">Supported Platforms</a></li>
   </ul><div class="footnote">
<hr>
<a name="texinfo-footnotes-in-document"></a><h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> Notably Microsoft's Internet Explorer
and Mozilla's Firefox, but not Apple's Safari.</p>

   <hr></div>

</body></html>

<!--

Local Variables:
coding: utf-8
End:

-->

Youez - 2016 - github.com/yon3zu
LinuXploit