[Tutorial][Base-Utils] Uset: add characters scenario
authorJozef Marek <j.marek2@samsung.com>
Fri, 7 Aug 2015 14:26:12 +0000 (16:26 +0200)
committerJozef Marek <j.marek2@samsung.com>
Tue, 11 Aug 2015 11:11:47 +0000 (13:11 +0200)
Change-Id: I1b77b6fe9ea1fa338543bd033fc79cc5ec24e4eb
Signed-off-by: Jozef Marek <j.marek2@samsung.com>
org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm

index 84f8787..79be505 100644 (file)
@@ -30,6 +30,7 @@
                        <li><a href="#ubrk">Managing Iteration Using Ubrk</a></li>
                        <li><a href="#uenum">Managing Enumerations</a></li>
                        <li><a href="#tmz">Managing Timezones</a></li>
+                       <li><a href="#uset">Managing Sets</a></li>
                </ul>
                <p class="toc-title">Related Info</p>
                <ul class="toc">
@@ -37,7 +38,7 @@
                        <li><a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__BASE__UTILS__I18N__MODULE.html">i18n API for Mobile Native</a></li>
                        <li><a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__BASE__UTILS__I18N__MODULE.html">i18n API for Wearable Native</a></li>
                </ul>
-       
+
     </div></div>
 </div>
 
 <h1>i18n: Managing Characters, Numbers, and Locales</h1>
 
 
-<p>This tutorial demonstrates how you can manage numbers, date, time and locale information.</p> 
+<p>This tutorial demonstrates how you can manage numbers, date, time and locale information.</p>
 <h2>Warm-up</h2>
 
- <p>Become familiar with the i18n API basics by learning about:</p> 
+ <p>Become familiar with the i18n API basics by learning about:</p>
                <ul>
                        <li><a href="#characters">Managing Characters and Strings</a>
                   <p>Convert and manage characters and strings.</p></li>
                   <li><a href="#dates">Managing Dates and Calendar</a>
                        <p>Manage dates and calendar.</p></li>
                   <li><a href="#locales">Managing Locales</a>
-                       <p>Manage locales, which represent a specific geographical, political, or cultural region.</p></li>     
+                       <p>Manage locales, which represent a specific geographical, political, or cultural region.</p></li>
                   <li><a href="#numbers">Managing Numbers</a>
                        <p>Format and parse numbers for any locale.</p></li>
                        <li><a href="#ubrk">Managing Iteration Using Ubrk</a>
                        <li><a href="#uenum">Managing Enumerations</a>
            <p>Create, acquire, and use enumerations.</p></li>
                   <li><a href="#tmz">Managing Timezones</a>
-            <p>Get the timezone name, ID, DST savings, raw offset, and region code.</p></li>
-               
+           <p>Get the timezone name, ID, DST savings, raw offset, and region code.</p></li>
+           <li><a href="#uset">Managing Sets</a>
+           <p>Manage sets of characters and strings.</p></li>
        </ul>
 
 <h2 id="characters" name="characters">Managing Characters and Strings</h2>
 
 
-         <table class="note"> 
-          <tbody> 
-               <tr> 
-                <th class="note">Note</th> 
-               </tr> 
-               <tr> 
+         <table class="note">
+          <tbody>
+               <tr>
+                <th class="note">Note</th>
+               </tr>
+               <tr>
                 <td class="note">
                 <ul><li>All source and destination buffers must be different.</li>
                 <li>To use the localization-related features of the i18n API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__BASE__UTILS__I18N__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__BASE__UTILS__I18N__MODULE.html">wearable</a> applications), include the <span style="font-family: Courier New,Courier,monospace">&lt;utils_i18n.h&gt;</span> header file in your application:
 <pre class="prettyprint">
 #include &lt;utils_i18n.h&gt;
-</pre></li></ul></td> 
-               </tr> 
-          </tbody> 
+</pre></li></ul></td>
+               </tr>
+          </tbody>
          </table>
 
 <h3 id="compare" name="compare">Comparing Ustrings</h3>
@@ -141,7 +143,7 @@ i18n_ucollator_str_collator(coll, s1, -1, s2, -1, &amp;result);
 <p>When you finish using the Ucollator, destroy it using the <span style="font-family: Courier New,Courier,monospace">i18n_ucollator_destroy()</span> function.</p>
 <pre class="prettyprint">
 i18n_ucollator_destroy(coll);
-</pre></li></ol>         
+</pre></li></ol>
 
 <h3 id="strings" name="strings">Converting Strings to Ustrings</h3>
 <p>To convert strings to Ustrings:</p>
@@ -590,7 +592,7 @@ const char *str = &quot;USD&quot;;
 i18n_unumber_set_symbol(num_format, I18N_UNUMBER_INTL_CURRENCY_SYMBOL, i18n_ustring_copy_ua(buffer, str), 3);</pre></li>
 
 <li>Get a locale associated with the number format.
-<p>To get a locale associated with the created number format, use the <span style="font-family: Courier New,Courier,monospace">i18n_unumber_get_locale_by_type()</span> function. The parameters are:</p> 
+<p>To get a locale associated with the created number format, use the <span style="font-family: Courier New,Courier,monospace">i18n_unumber_get_locale_by_type()</span> function. The parameters are:</p>
 <ul>
        <li>Number format</li>
        <li>Type of locale to get (see the <span style="font-family: Courier New,Courier,monospace">i18n_ulocale_data_locale_type_e</span> enumeration in documentation)</li>
@@ -828,7 +830,6 @@ int32_t dst_savings;
 i18n_timezone_get_dst_savings(tmz, &amp;dst_savings);
 </pre>
 <p>The result is returned in milliseconds (3600000 ms = 1 hour).</p></li>
-
 <li><p>To get the raw GMT offset:</p>
 <pre class="prettyprint">
 int32_t offset_milliseconds;
@@ -849,6 +850,70 @@ i18n_timezone_destroy(tmz);
 </pre></li></ol>
 
 
+<h2 id="uset" name="uset">Managing Sets</h2>
+<p>The Uset module allows you to create sets which can contain characters and strings. You can iterate through elements of the given set and carry out various operations on the set.</p>
+
+<p>To use Uset API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__BASE__UTILS__I18N__USET__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__BASE__UTILS__I18N__USET__MODULE.html">wearable</a> applications), include the <span style="font-family: Courier New,Courier,monospace">&lt;utils_i18n.h&gt;</span> header file in your application.</p>
+<li>
+The first step is to create a set. The code below creates an empty set:
+<pre>
+i18n_uset_h set;
+i18n_uset_create_empty(&amp;set);
+</pre>
+</li>
+
+<h3 id="create_enum" name="create_enum">Managing characters</h3>
+<p>The set can contain characters as its elements. It's also possible to check if a set contains specified characters.</p>
+<ol>
+<li>
+Add characters from a string to the set:
+<pre>
+const char *text = "Example string";
+i18n_uchar u_input_text[BUFLEN];
+i18n_ustring_copy_ua(u_input_text, text);
+
+i18n_uset_add_all_code_points(set, u_input_text, -1);
+</pre>
+</li>
+
+<li>
+Get the list of characters in the set:
+<pre>
+int chars_count = i18n_uset_size(set);
+int i;
+
+// Get all characters in the set
+for (i = 0; i < chars_count; i++) {
+    i18n_uchar32 uchar = i18n_uset_char_at(set, i);
+}
+</pre>
+</li>
+
+<li>
+Check whether the set contains the given character:
+<pre>
+i18n_ubool contains_character = i18n_uset_contains(set, 'a');
+</pre>
+</li>
+
+<li>
+Check whether the set contains characters from the a - c range:
+<pre>
+i18n_ubool contains_character = i18n_uset_contains_range(set, 'a', 'c');
+</pre>
+</li>
+
+<li>
+Check whether the set contains characters from another set:
+<pre>
+i18n_uset_h compare_set = NULL;
+// Fill the second set
+i18n_ubool contains_character = i18n_uset_contains_all(set, compare_set);
+</pre>
+</li>
+
+
+</ol>
        
 <script type="text/javascript" src="../../scripts/jquery.zclip.min.js"></script>
 <script type="text/javascript" src="../../scripts/showhide.js"></script>