<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.11"/> <title>ICU 58.2: upluralrules.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">ICU 58.2  <span id="projectnumber">58.2</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.11 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_b2f33c71d4aa5e7af42a1ca61ff5af1b.html">source</a></li><li class="navelem"><a class="el" href="dir_3c42bef9a3e7804b3d74ebb2809ebf86.html">i18n</a></li><li class="navelem"><a class="el" href="dir_fa4147b4d9cbc9ae7619e21b25239322.html">unicode</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#namespaces">Namespaces</a> | <a href="#typedef-members">Typedefs</a> | <a href="#enum-members">Enumerations</a> | <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">upluralrules.h File Reference</div> </div> </div><!--header--> <div class="contents"> <p>C API: Plural rules, select plural keywords for numeric values. <a href="#details">More...</a></p> <div class="textblock"><code>#include "<a class="el" href="utypes_8h_source.html">unicode/utypes.h</a>"</code><br /> <code>#include "<a class="el" href="localpointer_8h_source.html">unicode/localpointer.h</a>"</code><br /> </div> <p><a href="upluralrules_8h_source.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="namespaces"></a> Namespaces</h2></td></tr> <tr class="memitem:namespaceicu"><td class="memItemLeft" align="right" valign="top">  </td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceicu.html">icu</a></td></tr> <tr class="memdesc:namespaceicu"><td class="mdescLeft"> </td><td class="mdescRight">File <a class="el" href="coll_8h.html" title="C++ API: Collation Service. ">coll.h</a>. <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a> Typedefs</h2></td></tr> <tr class="memitem:ae51c4d4f471dc5d984e8fde4b5a2cfdc"><td class="memItemLeft" align="right" valign="top">typedef enum <a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3c">UPluralType</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="upluralrules_8h.html#ae51c4d4f471dc5d984e8fde4b5a2cfdc">UPluralType</a></td></tr> <tr class="separator:ae51c4d4f471dc5d984e8fde4b5a2cfdc"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a6fe07aecf6dfa5353e77be6c78e1ff36"><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a></td></tr> <tr class="memdesc:a6fe07aecf6dfa5353e77be6c78e1ff36"><td class="mdescLeft"> </td><td class="mdescRight">C typedef for struct UPluralRules. <a href="#a6fe07aecf6dfa5353e77be6c78e1ff36">More...</a><br /></td></tr> <tr class="separator:a6fe07aecf6dfa5353e77be6c78e1ff36"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a> Enumerations</h2></td></tr> <tr class="memitem:afceec9f2dee10dbf3ca0d694f66d5d3c"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3c">UPluralType</a> { <a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3ca5c9970165fa5b953848d6a055061eb07">UPLURAL_TYPE_CARDINAL</a>, <a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3ca5202122d3a4e2ad72d21879a7262aed0">UPLURAL_TYPE_ORDINAL</a>, <a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3ca94bf640d740f7669175139a6b0978adc">UPLURAL_TYPE_COUNT</a> }<tr class="memdesc:afceec9f2dee10dbf3ca0d694f66d5d3c"><td class="mdescLeft"> </td><td class="mdescRight">Type of plurals and PluralRules. <a href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3c">More...</a><br /></td></tr> </td></tr> <tr class="separator:afceec9f2dee10dbf3ca0d694f66d5d3c"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:a2118fdf77493a611db487c736c8378d1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="upluralrules_8h.html#a2118fdf77493a611db487c736c8378d1">uplrules_open</a> (const char *locale, <a class="el" href="utypes_8h.html#a3343c1c8a8377277046774691c98d78c">UErrorCode</a> *status)</td></tr> <tr class="memdesc:a2118fdf77493a611db487c736c8378d1"><td class="mdescLeft"> </td><td class="mdescRight">Opens a new UPluralRules object using the predefined cardinal-number plural rules for a given locale. <a href="#a2118fdf77493a611db487c736c8378d1">More...</a><br /></td></tr> <tr class="separator:a2118fdf77493a611db487c736c8378d1"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a1495538767c6f957b866792011477c89"><td class="memItemLeft" align="right" valign="top"><a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="upluralrules_8h.html#a1495538767c6f957b866792011477c89">uplrules_openForType</a> (const char *locale, <a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3c">UPluralType</a> type, <a class="el" href="utypes_8h.html#a3343c1c8a8377277046774691c98d78c">UErrorCode</a> *status)</td></tr> <tr class="memdesc:a1495538767c6f957b866792011477c89"><td class="mdescLeft"> </td><td class="mdescRight">Opens a new UPluralRules object using the predefined plural rules for a given locale and the plural type. <a href="#a1495538767c6f957b866792011477c89">More...</a><br /></td></tr> <tr class="separator:a1495538767c6f957b866792011477c89"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a5f8f8ef893e446e154f5be80d4f410eb"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="upluralrules_8h.html#a5f8f8ef893e446e154f5be80d4f410eb">uplrules_close</a> (<a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a> *uplrules)</td></tr> <tr class="memdesc:a5f8f8ef893e446e154f5be80d4f410eb"><td class="mdescLeft"> </td><td class="mdescRight">Closes a UPluralRules object. <a href="#a5f8f8ef893e446e154f5be80d4f410eb">More...</a><br /></td></tr> <tr class="separator:a5f8f8ef893e446e154f5be80d4f410eb"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ad2e1a8025cca2078e5a303802480540d"><td class="memItemLeft" align="right" valign="top">int32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="upluralrules_8h.html#ad2e1a8025cca2078e5a303802480540d">uplrules_select</a> (const <a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a> *uplrules, double number, <a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a> *keyword, int32_t capacity, <a class="el" href="utypes_8h.html#a3343c1c8a8377277046774691c98d78c">UErrorCode</a> *status)</td></tr> <tr class="memdesc:ad2e1a8025cca2078e5a303802480540d"><td class="mdescLeft"> </td><td class="mdescRight">Given a number, returns the keyword of the first rule that applies to the number, according to the supplied UPluralRules object. <a href="#ad2e1a8025cca2078e5a303802480540d">More...</a><br /></td></tr> <tr class="separator:ad2e1a8025cca2078e5a303802480540d"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>C API: Plural rules, select plural keywords for numeric values. </p> <p>A UPluralRules object defines rules for mapping non-negative numeric values onto a small set of keywords. Rules are constructed from a text description, consisting of a series of keywords and conditions. The uplrules_select function examines each condition in order and returns the keyword for the first condition that matches the number. If none match, the default rule(other) is returned.</p> <p>For more information, see the LDML spec, C.11 Language Plural Rules: <a href="http://www.unicode.org/reports/tr35/#Language_Plural_Rules">http://www.unicode.org/reports/tr35/#Language_Plural_Rules</a></p> <p>Keywords: ICU locale data has 6 predefined values - 'zero', 'one', 'two', 'few', 'many' and 'other'. Callers need to check the value of keyword returned by the uplrules_select function.</p> <p>These are based on CLDR <em>Language Plural Rules</em>. For these predefined rules, see the CLDR page at <a href="http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html">http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html</a> </p> <p>Definition in file <a class="el" href="upluralrules_8h_source.html">upluralrules.h</a>.</p> </div><h2 class="groupheader">Typedef Documentation</h2> <a class="anchor" id="a6fe07aecf6dfa5353e77be6c78e1ff36"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">typedef struct <a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a> <a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a></td> </tr> </table> </div><div class="memdoc"> <p>C typedef for struct UPluralRules. </p> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable005400">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> <p>Definition at line <a class="el" href="upluralrules_8h_source.html#l00075">75</a> of file <a class="el" href="upluralrules_8h_source.html">upluralrules.h</a>.</p> </div> </div> <a class="anchor" id="ae51c4d4f471dc5d984e8fde4b5a2cfdc"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">typedef enum <a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3c">UPluralType</a> <a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3c">UPluralType</a></td> </tr> </table> </div><div class="memdoc"> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable005398">Stable:</a></b></dt><dd>ICU 50 </dd></dl> <p>Definition at line <a class="el" href="upluralrules_8h_source.html#l00068">68</a> of file <a class="el" href="upluralrules_8h_source.html">upluralrules.h</a>.</p> </div> </div> <h2 class="groupheader">Enumeration Type Documentation</h2> <a class="anchor" id="afceec9f2dee10dbf3ca0d694f66d5d3c"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">enum <a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3c">UPluralType</a></td> </tr> </table> </div><div class="memdoc"> <p>Type of plurals and PluralRules. </p> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable005397">Stable:</a></b></dt><dd>ICU 50 </dd></dl> <table class="fieldtable"> <tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a class="anchor" id="afceec9f2dee10dbf3ca0d694f66d5d3ca5c9970165fa5b953848d6a055061eb07"></a>UPLURAL_TYPE_CARDINAL </td><td class="fielddoc"> <p>Plural rules for cardinal numbers: 1 file vs. </p> <p>2 files. </p><dl class="stable"><dt><b><a class="el" href="stable.html#_stable005405">Stable:</a></b></dt><dd>ICU 50 </dd></dl> </td></tr> <tr><td class="fieldname"><a class="anchor" id="afceec9f2dee10dbf3ca0d694f66d5d3ca5202122d3a4e2ad72d21879a7262aed0"></a>UPLURAL_TYPE_ORDINAL </td><td class="fielddoc"> <p>Plural rules for ordinal numbers: 1st file, 2nd file, 3rd file, 4th file, etc. </p> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable005406">Stable:</a></b></dt><dd>ICU 50 </dd></dl> </td></tr> <tr><td class="fieldname"><a class="anchor" id="afceec9f2dee10dbf3ca0d694f66d5d3ca94bf640d740f7669175139a6b0978adc"></a>UPLURAL_TYPE_COUNT </td><td class="fielddoc"> <p>One more than the highest normal UPluralType value. </p> <dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000428">Deprecated:</a></b></dt><dd>ICU 58 The numeric value may change over time, see ICU ticket #12420. </dd></dl> </td></tr> </table> <p>Definition at line <a class="el" href="upluralrules_8h_source.html#l00046">46</a> of file <a class="el" href="upluralrules_8h_source.html">upluralrules.h</a>.</p> </div> </div> <h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="a5f8f8ef893e446e154f5be80d4f410eb"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void uplrules_close </td> <td>(</td> <td class="paramtype"><a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a> * </td> <td class="paramname"><em>uplrules</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Closes a UPluralRules object. </p> <p>Once closed it may no longer be used. </p><dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">uplrules</td><td>The UPluralRules object to close. </td></tr> </table> </dd> </dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable005403">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> </div> </div> <a class="anchor" id="a2118fdf77493a611db487c736c8378d1"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a>* uplrules_open </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>locale</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="utypes_8h.html#a3343c1c8a8377277046774691c98d78c">UErrorCode</a> * </td> <td class="paramname"><em>status</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Opens a new UPluralRules object using the predefined cardinal-number plural rules for a given locale. </p> <p>Same as uplrules_openForType(locale, UPLURAL_TYPE_CARDINAL, status). </p><dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">locale</td><td>The locale for which the rules are desired. </td></tr> <tr><td class="paramname">status</td><td>A pointer to a UErrorCode to receive any errors. </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>A UPluralRules for the specified locale, or NULL if an error occurred. </dd></dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable005401">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> </div> </div> <a class="anchor" id="a1495538767c6f957b866792011477c89"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a>* uplrules_openForType </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>locale</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="upluralrules_8h.html#afceec9f2dee10dbf3ca0d694f66d5d3c">UPluralType</a> </td> <td class="paramname"><em>type</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="utypes_8h.html#a3343c1c8a8377277046774691c98d78c">UErrorCode</a> * </td> <td class="paramname"><em>status</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Opens a new UPluralRules object using the predefined plural rules for a given locale and the plural type. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">locale</td><td>The locale for which the rules are desired. </td></tr> <tr><td class="paramname">type</td><td>The plural type (e.g., cardinal or ordinal). </td></tr> <tr><td class="paramname">status</td><td>A pointer to a UErrorCode to receive any errors. </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>A UPluralRules for the specified locale, or NULL if an error occurred. </dd></dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable005402">Stable:</a></b></dt><dd>ICU 50 </dd></dl> </div> </div> <a class="anchor" id="ad2e1a8025cca2078e5a303802480540d"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int32_t uplrules_select </td> <td>(</td> <td class="paramtype">const <a class="el" href="upluralrules_8h.html#a6fe07aecf6dfa5353e77be6c78e1ff36">UPluralRules</a> * </td> <td class="paramname"><em>uplrules</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">double </td> <td class="paramname"><em>number</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="umachine_8h.html#a6bb9fad572d65b305324ef288165e2ac">UChar</a> * </td> <td class="paramname"><em>keyword</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32_t </td> <td class="paramname"><em>capacity</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="utypes_8h.html#a3343c1c8a8377277046774691c98d78c">UErrorCode</a> * </td> <td class="paramname"><em>status</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Given a number, returns the keyword of the first rule that applies to the number, according to the supplied UPluralRules object. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">uplrules</td><td>The UPluralRules object specifying the rules. </td></tr> <tr><td class="paramname">number</td><td>The number for which the rule has to be determined. </td></tr> <tr><td class="paramname">keyword</td><td>The keyword of the rule that applies to number. </td></tr> <tr><td class="paramname">capacity</td><td>The capacity of keyword. </td></tr> <tr><td class="paramname">status</td><td>A pointer to a UErrorCode to receive any errors. </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>The length of keyword. </dd></dl> <dl class="stable"><dt><b><a class="el" href="stable.html#_stable005404">Stable:</a></b></dt><dd>ICU 4.8 </dd></dl> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.11 </small></address> </body> </html>