libidn-punycode.html   [plain text]


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>punycode</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.71.0">
<link rel="start" href="index.html" title="GNU Libidn API Reference Manual">
<link rel="up" href="ch01.html" title="GNU Libidn API Reference Manual">
<link rel="prev" href="libidn-pr29.html" title="pr29">
<link rel="next" href="libidn-tld.html" title="tld">
<meta name="generator" content="GTK-Doc V1.7 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="ch01.html" title="GNU Libidn API Reference Manual">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="libidn-pr29.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GNU Libidn API Reference Manual</th>
<td><a accesskey="n" href="libidn-tld.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2558276" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id2561532" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="libidn-punycode"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2558276"></a><span class="refentrytitle">punycode</span>
</h2>
<p>punycode</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">



enum        <a href="libidn-punycode.html#Punycode-status">Punycode_status</a>;
const char* <a href="libidn-punycode.html#punycode-strerror">punycode_strerror</a>               (<a href="libidn-punycode.html#Punycode-status">Punycode_status</a> rc);
typedef     <a href="libidn-punycode.html#punycode-uint">punycode_uint</a>;
int         <a href="libidn-punycode.html#punycode-encode">punycode_encode</a>                 (size_t input_length,
                                             const <a href="libidn-punycode.html#punycode-uint">punycode_uint</a> input[],
                                             unsigned char case_flags[],
                                             size_t *output_length,
                                             char output[]);
int         <a href="libidn-punycode.html#punycode-decode">punycode_decode</a>                 (size_t input_length,
                                             const char input[],
                                             size_t *output_length,
                                             <a href="libidn-punycode.html#punycode-uint">punycode_uint</a> output[],
                                             unsigned char case_flags[]);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2561532"></a><h2>Description</h2>
<p>

</p>
</div>
<div class="refsect1" lang="en">
<a name="id2561547"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2561558"></a><h3>
<a name="Punycode-status"></a>enum Punycode_status</h3>
<a class="indexterm" name="id2561571"></a><pre class="programlisting">  typedef enum
  {
    PUNYCODE_SUCCESS = punycode_success,
    PUNYCODE_BAD_INPUT = punycode_bad_input,
    PUNYCODE_BIG_OUTPUT = punycode_big_output,
    PUNYCODE_OVERFLOW = punycode_overflow
  } Punycode_status;
</pre>
<p>
Enumerated return codes of <a href="libidn-punycode.html#punycode-encode"><code class="function">punycode_encode()</code></a> and <a href="libidn-punycode.html#punycode-decode"><code class="function">punycode_decode()</code></a>.
The value 0 is guaranteed to always correspond to success.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><a name="PUNYCODE-SUCCESS:CAPS"></a><code class="literal">PUNYCODE_SUCCESS</code></span></td>
<td> 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.
</td>
</tr>
<tr>
<td><span class="term"><a name="PUNYCODE-BAD-INPUT:CAPS"></a><code class="literal">PUNYCODE_BAD_INPUT</code></span></td>
<td> Input is invalid.
</td>
</tr>
<tr>
<td><span class="term"><a name="PUNYCODE-BIG-OUTPUT:CAPS"></a><code class="literal">PUNYCODE_BIG_OUTPUT</code></span></td>
<td> Output would exceed the space provided.
</td>
</tr>
<tr>
<td><span class="term"><a name="PUNYCODE-OVERFLOW:CAPS"></a><code class="literal">PUNYCODE_OVERFLOW</code></span></td>
<td> Input needs wider integers to process.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2568510"></a><h3>
<a name="punycode-strerror"></a>punycode_strerror ()</h3>
<a class="indexterm" name="id2568522"></a><pre class="programlisting">const char* punycode_strerror               (<a href="libidn-punycode.html#Punycode-status">Punycode_status</a> rc);</pre>
<p>
Convert a return code integer to a text string.  This string can be
used to output a diagnostic message to the user.
</p>
<p>
PUNYCODE_SUCCESS: 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.
PUNYCODE_BAD_INPUT: Input is invalid.
PUNYCODE_BIG_OUTPUT: Output would exceed the space provided.
PUNYCODE_OVERFLOW: Input needs wider integers to process.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>rc</code></em>&#160;:</span></td>
<td> an <a href="libidn-punycode.html#Punycode-status"><span class="type">Punycode_status</span></a> return code.
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> Returns a pointer to a statically allocated string
containing a description of the error with the return code <em class="parameter"><code>rc</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2568609"></a><h3>
<a name="punycode-uint"></a>punycode_uint</h3>
<a class="indexterm" name="id2568621"></a><pre class="programlisting">  typedef uint32_t punycode_uint;
</pre>
<p>
Unicode code point data type, this is always a 32 bit unsigned
integer.</p>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2568642"></a><h3>
<a name="punycode-encode"></a>punycode_encode ()</h3>
<a class="indexterm" name="id2568654"></a><pre class="programlisting">int         punycode_encode                 (size_t input_length,
                                             const <a href="libidn-punycode.html#punycode-uint">punycode_uint</a> input[],
                                             unsigned char case_flags[],
                                             size_t *output_length,
                                             char output[]);</pre>
<p>
Converts a sequence of code points (presumed to be Unicode code
points) to Punycode.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>input_length</code></em>&#160;:</span></td>
<td> The number of code points in the <em class="parameter"><code>input</code></em> array and
  the number of flags in the <em class="parameter"><code>case_flags</code></em> array.
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>input</code></em>&#160;:</span></td>
<td> 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.
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>case_flags</code></em>&#160;:</span></td>
<td> A <code class="literal">NULL</code> pointer or an array of boolean values parallel
  to the <em class="parameter"><code>input</code></em> 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 <em class="parameter"><code>case_flags</code></em> is a <code class="literal">NULL</code> pointer then ASCII letters
  are left as they are, and other code points are treated as
  unflagged.
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>output_length</code></em>&#160;:</span></td>
<td> 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.
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>output</code></em>&#160;:</span></td>
<td> An array of ASCII code points.  It is *not*
  null-terminated; it will contain zeros if and only if the <em class="parameter"><code>input</code></em>
  contains zeros.  (Of course the caller can leave room for a
  terminator and add one if needed.)
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> The return value can be any of the <a href="libidn-punycode.html#Punycode-status"><span class="type">Punycode_status</span></a>
  values defined above except <a href="libidn-punycode.html#PUNYCODE-BAD-INPUT:CAPS"><code class="literal">PUNYCODE_BAD_INPUT</code></a>.  If not
  <a href="libidn-punycode.html#PUNYCODE-SUCCESS:CAPS"><code class="literal">PUNYCODE_SUCCESS</code></a>, then <em class="parameter"><code>output_size</code></em> and <em class="parameter"><code>output</code></em> might contain
  garbage.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2592950"></a><h3>
<a name="punycode-decode"></a>punycode_decode ()</h3>
<a class="indexterm" name="id2592963"></a><pre class="programlisting">int         punycode_decode                 (size_t input_length,
                                             const char input[],
                                             size_t *output_length,
                                             <a href="libidn-punycode.html#punycode-uint">punycode_uint</a> output[],
                                             unsigned char case_flags[]);</pre>
<p>
Converts Punycode to a sequence of code points (presumed to be
Unicode code points).</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>input_length</code></em>&#160;:</span></td>
<td> The number of ASCII code points in the <em class="parameter"><code>input</code></em> array.
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>input</code></em>&#160;:</span></td>
<td> An array of ASCII code points (0..7F).
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>output_length</code></em>&#160;:</span></td>
<td> The caller passes in the maximum number of code
  points that it can receive into the <em class="parameter"><code>output</code></em> array (which is also
  the maximum number of flags that it can receive into the
  <em class="parameter"><code>case_flags</code></em> array, if <em class="parameter"><code>case_flags</code></em> is not a <code class="literal">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
  <em class="parameter"><code>output_length</code></em> is greater than that.
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>output</code></em>&#160;:</span></td>
<td> An array of code points like the input argument of
  <a href="libidn-punycode.html#punycode-encode"><code class="function">punycode_encode()</code></a> (see above).
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>case_flags</code></em>&#160;:</span></td>
<td> A <code class="literal">NULL</code> pointer (if the flags are not needed by the
  caller) or an array of boolean values parallel to the <em class="parameter"><code>output</code></em>
  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.
</td>
</tr>
<tr>
<td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> The return value can be any of the <a href="libidn-punycode.html#Punycode-status"><span class="type">Punycode_status</span></a>
  values defined above.  If not <a href="libidn-punycode.html#PUNYCODE-SUCCESS:CAPS"><code class="literal">PUNYCODE_SUCCESS</code></a>, then
  <em class="parameter"><code>output_length</code></em>, <em class="parameter"><code>output</code></em>, and <em class="parameter"><code>case_flags</code></em> might contain garbage.

</td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
</body>
</html>