1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
|
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="libidn-punycode">
<refmeta>
<refentrytitle role="top_of_page" id="libidn-punycode.top_of_page">punycode</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>LIBIDN Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>punycode</refname>
<refpurpose></refpurpose>
</refnamediv>
<refsynopsisdiv id="libidn-punycode.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>
<synopsis>
#define <link linkend="IDNAPI--CAPS">IDNAPI</link>
enum <link linkend="Punycode-status">Punycode_status</link>;
const <link linkend="char">char</link> * <link linkend="punycode-strerror">punycode_strerror</link> (<link linkend="Punycode-status">Punycode_status</link> rc);
typedef <link linkend="punycode-uint">punycode_uint</link>;
<link linkend="int">int</link> <link linkend="punycode-encode">punycode_encode</link> (<link linkend="size-t">size_t</link> input_length,
const <link linkend="punycode-uint">punycode_uint</link> input[],
unsigned <link linkend="char">char</link> case_flags[],
<link linkend="size-t">size_t</link> *output_length,
<link linkend="char">char</link> output[]);
<link linkend="int">int</link> <link linkend="punycode-decode">punycode_decode</link> (<link linkend="size-t">size_t</link> input_length,
const <link linkend="char">char</link> input[],
<link linkend="size-t">size_t</link> *output_length,
<link linkend="punycode-uint">punycode_uint</link> output[],
unsigned <link linkend="char">char</link> case_flags[]);
</synopsis>
</refsynopsisdiv>
<refsect1 id="libidn-punycode.description" role="desc">
<title role="desc.title">Description</title>
<para>
</para>
</refsect1>
<refsect1 id="libidn-punycode.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="IDNAPI--CAPS" role="macro">
<title>IDNAPI</title>
<indexterm zone="IDNAPI--CAPS"><primary sortas="IDNAPI">IDNAPI</primary></indexterm><programlisting>#define IDNAPI</programlisting>
<para>
</para></refsect2>
<refsect2 id="Punycode-status" role="enum">
<title>enum Punycode_status</title>
<indexterm zone="Punycode-status"><primary sortas="Punycode_status">Punycode_status</primary></indexterm><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;
</programlisting>
<para>
Enumerated return codes of <link linkend="punycode-encode"><function>punycode_encode()</function></link> and <link linkend="punycode-decode"><function>punycode_decode()</function></link>.
The value 0 is guaranteed to always correspond to success.</para>
<para>
</para><variablelist role="enum">
<varlistentry id="PUNYCODE-SUCCESS--CAPS" role="constant">
<term><literal>PUNYCODE_SUCCESS</literal></term>
<listitem><simpara> 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.
</simpara></listitem>
</varlistentry>
<varlistentry id="PUNYCODE-BAD-INPUT--CAPS" role="constant">
<term><literal>PUNYCODE_BAD_INPUT</literal></term>
<listitem><simpara> Input is invalid.
</simpara></listitem>
</varlistentry>
<varlistentry id="PUNYCODE-BIG-OUTPUT--CAPS" role="constant">
<term><literal>PUNYCODE_BIG_OUTPUT</literal></term>
<listitem><simpara> Output would exceed the space provided.
</simpara></listitem>
</varlistentry>
<varlistentry id="PUNYCODE-OVERFLOW--CAPS" role="constant">
<term><literal>PUNYCODE_OVERFLOW</literal></term>
<listitem><simpara> Input needs wider integers to process.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="punycode-strerror" role="function">
<title>punycode_strerror ()</title>
<indexterm zone="punycode-strerror"><primary sortas="punycode_strerror">punycode_strerror</primary></indexterm><programlisting>const <link linkend="char">char</link> * punycode_strerror (<link linkend="Punycode-status">Punycode_status</link> rc);</programlisting>
<para>
Convert a return code integer to a text string. This string can be
used to output a diagnostic message to the user.
</para>
<para>
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.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>rc</parameter> :</term>
<listitem><simpara> an <link linkend="Punycode-status"><type>Punycode_status</type></link> return code.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> Returns a pointer to a statically allocated string
containing a description of the error with the return code <parameter>rc</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="punycode-uint" role="typedef">
<title>punycode_uint</title>
<indexterm zone="punycode-uint"><primary sortas="punycode_uint">punycode_uint</primary></indexterm><programlisting> typedef uint32_t punycode_uint;
</programlisting>
<para>
Unicode code point data type, this is always a 32 bit unsigned
integer.</para>
<para>
</para></refsect2>
<refsect2 id="punycode-encode" role="function">
<title>punycode_encode ()</title>
<indexterm zone="punycode-encode"><primary sortas="punycode_encode">punycode_encode</primary></indexterm><programlisting><link linkend="int">int</link> punycode_encode (<link linkend="size-t">size_t</link> input_length,
const <link linkend="punycode-uint">punycode_uint</link> input[],
unsigned <link linkend="char">char</link> case_flags[],
<link linkend="size-t">size_t</link> *output_length,
<link linkend="char">char</link> output[]);</programlisting>
<para>
Converts a sequence of code points (presumed to be Unicode code
points) to Punycode.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>input_length</parameter> :</term>
<listitem><simpara> The number of code points in the <parameter>input</parameter> array and
the number of flags in the <parameter>case_flags</parameter> array.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>input</parameter> :</term>
<listitem><simpara> 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.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>case_flags</parameter> :</term>
<listitem><simpara> A <link linkend="NULL--CAPS"><literal>NULL</literal></link> pointer or an array of boolean values parallel
to the <parameter>input</parameter> 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 <parameter>case_flags</parameter> is a <link linkend="NULL--CAPS"><literal>NULL</literal></link> pointer then ASCII letters
are left as they are, and other code points are treated as
unflagged.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>output_length</parameter> :</term>
<listitem><simpara> 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.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>output</parameter> :</term>
<listitem><simpara> An array of ASCII code points. It is *not*
null-terminated; it will contain zeros if and only if the <parameter>input</parameter>
contains zeros. (Of course the caller can leave room for a
terminator and add one if needed.)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> The return value can be any of the <link linkend="Punycode-status"><type>Punycode_status</type></link>
values defined above except <link linkend="PUNYCODE-BAD-INPUT--CAPS"><literal>PUNYCODE_BAD_INPUT</literal></link>. If not
<link linkend="PUNYCODE-SUCCESS--CAPS"><literal>PUNYCODE_SUCCESS</literal></link>, then <parameter>output_size</parameter> and <parameter>output</parameter> might contain
garbage.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="punycode-decode" role="function">
<title>punycode_decode ()</title>
<indexterm zone="punycode-decode"><primary sortas="punycode_decode">punycode_decode</primary></indexterm><programlisting><link linkend="int">int</link> punycode_decode (<link linkend="size-t">size_t</link> input_length,
const <link linkend="char">char</link> input[],
<link linkend="size-t">size_t</link> *output_length,
<link linkend="punycode-uint">punycode_uint</link> output[],
unsigned <link linkend="char">char</link> case_flags[]);</programlisting>
<para>
Converts Punycode to a sequence of code points (presumed to be
Unicode code points).</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>input_length</parameter> :</term>
<listitem><simpara> The number of ASCII code points in the <parameter>input</parameter> array.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>input</parameter> :</term>
<listitem><simpara> An array of ASCII code points (0..7F).
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>output_length</parameter> :</term>
<listitem><simpara> The caller passes in the maximum number of code
points that it can receive into the <parameter>output</parameter> array (which is also
the maximum number of flags that it can receive into the
<parameter>case_flags</parameter> array, if <parameter>case_flags</parameter> is not a <link linkend="NULL--CAPS"><literal>NULL</literal></link> 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
<parameter>output_length</parameter> is greater than that.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>output</parameter> :</term>
<listitem><simpara> An array of code points like the input argument of
<link linkend="punycode-encode"><function>punycode_encode()</function></link> (see above).
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>case_flags</parameter> :</term>
<listitem><simpara> A <link linkend="NULL--CAPS"><literal>NULL</literal></link> pointer (if the flags are not needed by the
caller) or an array of boolean values parallel to the <parameter>output</parameter>
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.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> The return value can be any of the <link linkend="Punycode-status"><type>Punycode_status</type></link>
values defined above. If not <link linkend="PUNYCODE-SUCCESS--CAPS"><literal>PUNYCODE_SUCCESS</literal></link>, then
<parameter>output_length</parameter>, <parameter>output</parameter>, and <parameter>case_flags</parameter> might contain garbage.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
</refsect1>
</refentry>
|