[base][i18n] Tutorial description updated
authorBeata Stefaniuk <b.stefaniuk@samsung.com>
Tue, 8 Dec 2015 15:06:41 +0000 (16:06 +0100)
committerBeata Stefaniuk <b.stefaniuk@samsung.com>
Tue, 8 Dec 2015 15:14:08 +0000 (16:14 +0100)
Change-Id: Ic92569db23c0e6b870c8028f32523cbc66260d44
Signed-off-by: Beata Stefaniuk <b.stefaniuk@samsung.com>
org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm

index 9a0f240..6d31645 100644 (file)
 <ol>
 <li><p>To compare 2 Ustrings for bitwise equality, use the <span style="font-family: Courier New,Courier,monospace">i18n_ustring_compare()</span> function. The obtained result is equal to 0 if the compared Ustrings are equal. The result is a negative value if the first Ustring is bitwise smaller than the second Ustring, and a positive value if the first Ustring is greater than the second one.</p>
 <pre class="prettyprint">
-#define BUFLEN 400
+#define BUF_SIZE 64
 
-i18n_uchar s1[BUFLEN];
+i18n_uchar s1[BUF_SIZE];
 i18n_ustring_copy_ua(s1, &quot;Tizen&quot;);
-i18n_uchar s2[BUFLEN];
+i18n_uchar s2[BUF_SIZE];
 i18n_ustring_copy_ua(s2, &quot;Bada&quot;);
 int32_t result = i18n_ustring_compare(s1, s2);
 </pre></li></ol>
@@ -153,14 +153,14 @@ i18n_ucollator_destroy(coll);
 <ul><li><p>To convert a byte string to a Unicode string (Ustring), use the <span style="font-family: Courier New,Courier,monospace">i18n_ustring_copy_ua()</span> function.</p>
 <pre class="prettyprint">
 const char *src = &quot;Tizen&quot;;
-i18n_uchar dest[BUFLEN];
+i18n_uchar dest[BUF_SIZE];
 i18n_ustring_copy_ua(dest, src);
 </pre></li>
 <li><p>The <span style="font-family: Courier New,Courier,monospace">i18n_ustring_copy_ua_n()</span> function works similarly but it copies n characters at most, where n is its third parameter.</p>
 <pre class="prettyprint">
 const char *src = &quot;Tizen&quot;;
-i18n_uchar dest[BUFLEN];
-i18n_ustring_copy_ua_n(dest, src, BUFLEN);
+i18n_uchar dest[BUF_SIZE];
+i18n_ustring_copy_ua_n(dest, src, BUF_SIZE);
 </pre></li>
 <li><p>Another way to convert a string to a Ustring is using the <span style="font-family: Courier New,Courier,monospace">i18n_ustring_from_UTF8()</span> function. Its parameters are:</p>
 <ul>
@@ -173,10 +173,10 @@ i18n_ustring_copy_ua_n(dest, src, BUFLEN);
 </ul>
 <pre class="prettyprint">
 const char *src = &quot;Tizen&quot;;
-i18n_uchar dest[BUFLEN];
+i18n_uchar dest[BUF_SIZE];
 int dest_len;
 i18n_uerror_code_e error_code = I18N_ERROR_NONE;
-i18n_ustring_from_UTF8(dest, BUFLEN, &amp;dest_len, src, -1, &amp;error_code);
+i18n_ustring_from_UTF8(dest, BUF_SIZE, &amp;dest_len, src, -1, &amp;error_code);
 </pre></li></ul>
 
 <h3 id="ustrings" name="ustrings">Converting Ustrings to Strings</h3>
@@ -185,17 +185,17 @@ i18n_ustring_from_UTF8(dest, BUFLEN, &amp;dest_len, src, -1, &amp;error_code);
 <ul>
 <li><p>To convert a Ustring to a byte string, use the <span style="font-family: Courier New,Courier,monospace">i18n_ustring_copy_au()</span> function.</p>
 <pre class="prettyprint">
-i18n_uchar src[BUFLEN];
+i18n_uchar src[BUF_SIZE];
 i18n_ustring_copy_ua(src, &quot;Tizen&quot;);
-const char dest[BUFLEN];
+char dest[BUF_SIZE];
 i18n_ustring_copy_au(dest, src);
 </pre></li>
 <li><p>The <span style="font-family: Courier New,Courier,monospace">i18n_ustring_copy_au_n()</span> function works similarly but it copies n characters at most, where n is its third parameter.</p>
 <pre class="prettyprint">
-i18n_uchar src[BUFLEN];
+i18n_uchar src[BUF_SIZE];
 i18n_ustring_copy_ua(src, &quot;Tizen&quot;);
-const char dest[BUFLEN];
-i18n_ustring_copy_au_n(dest, src, BUFLEN);
+char dest[BUF_SIZE];
+i18n_ustring_copy_au_n(dest, src, BUF_SIZE);
 </pre></li>
 
 <li><p>Another way to convert a Ustring to a string is using the <span style="font-family: Courier New,Courier,monospace">i18n_ustring_to_UTF8()</span> function. Its parameters are:</p>
@@ -210,12 +210,12 @@ i18n_ustring_copy_au_n(dest, src, BUFLEN);
 <p>To get the length of a Ustring, use the <span style="font-family: Courier New,Courier,monospace">i18n_ustring_get_length()</span> function.</p>
 
 <pre class="prettyprint">
-i18n_uchar src[BUFLEN];
+i18n_uchar src[BUF_SIZE];
 i18n_ustring_copy_ua(src, &quot;Tizen&quot;);
-const char dest[BUFLEN];
+char dest[BUF_SIZE];
 int dest_len;
 i18n_uerror_code_e error_code = I18N_ERROR_NONE;
-i18n_ustring_to_UTF8(dest, BUFLEN, &amp;dest_len, src, i18n_ustring_get_length(src), &amp;error_code);
+i18n_ustring_to_UTF8(dest, BUF_SIZE, &amp;dest_len, src, i18n_ustring_get_length(src), &amp;error_code);
 </pre></li></ul>
 
 <h3 id="unicode" name="unicode">Getting Unicode Block of a Character</h3>
@@ -286,9 +286,9 @@ i18n_unormalization_normalize(normalizer, &amp;src, 1, dest, 4, &amp;dest_str_le
        <li>Handle to created search iterator</li>
 </ul>
 <pre class="prettyprint">
-i18n_uchar text[BUFLEN];
+i18n_uchar text[BUF_SIZE];
 i18n_ustring_copy_ua(text, &quot;TIZEN&quot;);
-i18n_uchar pattern[BUFLEN];
+i18n_uchar pattern[BUF_SIZE];
 i18n_ustring_copy_ua(pattern, &quot;ZEN&quot;);
 i18n_usearch_h usearch;
 i18n_usearch_create_new(pattern, -1, text, -1, I18N_ULOCALE_US, NULL, &amp;usearch);
@@ -321,11 +321,11 @@ i18n_usearch_destroy(usearch);
 </ul>
 
 <pre class="prettyprint">
-i18n_uchar src[BUFLEN];
+i18n_uchar src[BUF_SIZE];
 i18n_ustring_copy_ua(src, &quot;Tizen&quot;);
-i18n_uchar dest[BUFLEN];
-i18n_ustring_to_upper(dest, BUFLEN, src, -1, I18N_ULOCALE_US, &amp;error_code);
-i18n_ustring_to_lower(dest, BUFLEN, src, -1, I18N_ULOCALE_US, &amp;error_code);
+i18n_uchar dest[BUF_SIZE];
+i18n_ustring_to_upper(dest, BUF_SIZE, src, -1, I18N_ULOCALE_US, &amp;error_code);
+i18n_ustring_to_lower(dest, BUF_SIZE, src, -1, I18N_ULOCALE_US, &amp;error_code);
 </pre>
 </li>
 <li><p>To change the string case to title case, use the <span style="font-family: Courier New,Courier,monospace">i18n_ustring_to_title_new()</span> function. The parameters are:</p>
@@ -338,10 +338,10 @@ i18n_ustring_to_lower(dest, BUFLEN, src, -1, I18N_ULOCALE_US, &amp;error_code);
        <li>Locale (<span style="font-family: Courier New,Courier,monospace">&quot;&quot;</span> for root locale, NULL for default locale</li>
 </ul>
 <pre class="prettyprint">
-i18n_uchar src[BUFLEN];
+i18n_uchar src[BUF_SIZE];
 i18n_ustring_copy_ua(src, &quot;Tizen&quot;);
-i18n_uchar dest[BUFLEN];
-i18n_ustring_to_title_new(dest, BUFLEN, src, BUFLEN, NULL, NULL);
+i18n_uchar dest[BUF_SIZE];
+i18n_ustring_to_title_new(dest, BUF_SIZE, src, BUF_SIZE, NULL, NULL);
 </pre>
 </li>
 </ol>
@@ -357,11 +357,12 @@ i18n_ustring_to_title_new(dest, BUFLEN, src, BUFLEN, NULL, NULL);
 </ul>
 <p>Alternatively, you can use <span style="font-family: Courier New,Courier,monospace">18n_ustring_cat()</span>, which does not take the last parameter.</p>
 <pre class="prettyprint">
-i18n_uchar src[BUFLEN];
-i18n_uchar dest[BUFLEN];
-i18n_ustring_copy_ua(src, &quot;Destination string&quot;);
+i18n_uchar src[BUF_SIZE];
+i18n_uchar dest[BUF_SIZE];
+i18n_ustring_copy_ua(dest, &quot;Destination string&quot;);
 i18n_ustring_copy_ua(src, &quot;Appended string&quot;);
-i18n_ustring_cat_n(dest, src, BUFLEN);
+i18n_ustring_cat_n(dest, src, BUF_SIZE);
+// Or
 i18n_ustring_cat(dest, src);
 </pre>
 </li>
@@ -370,7 +371,7 @@ i18n_ustring_cat(dest, src);
 <h3 id="substring" name="substring">Finding a Substring</h3>
 <p>To find a substring in a Ustring:</p>
 <ol>
-<li><p>Use the <span style="font-family: Courier New,Courier,monospace">18n_ustring_string()</span> functions. The parameters are:</p>
+<li><p>Use the <span style="font-family: Courier New,Courier,monospace">i18n_ustring_string()</span> functions. The parameters are:</p>
 <ul>
        <li>String</li>
        <li>Substring which the function searches for in the string</li>
@@ -378,8 +379,8 @@ i18n_ustring_cat(dest, src);
 <p>The result is a pointer to the first occurrence of the substring, or NULL if the substring is not found. You can use pointer arithmetic to find the index of the character at which the first occurrence begins.</p>
 
 <pre class="prettyprint">
-i18n_uchar s[BUFLEN];
-i18n_uchar substring[BUFLEN];
+i18n_uchar s[BUF_SIZE];
+i18n_uchar substring[BUF_SIZE];
 
 i18n_uchar *result = i18n_ustring_string(s, substr);
 
@@ -422,8 +423,10 @@ else
     <li>Handle to the created Ucalendar</li>
 </ul>
 <pre class="prettyprint">
-i18n_uchar timezone[17];
-i18n_ustring_copy_ua_n(timezone, &quot;America/New_York&quot;, 17);
+i18n_uchar timezone[BUF_SIZE];
+const char *timezone_name = &quot;America/New_York&quot;;
+int timezone_name_len = strlen(timezone_name);
+i18n_ustring_copy_ua_n(timezone, timezone_name, timezone_name_len+1);
 i18n_ucalendar_h ucalendar;
 i18n_ucalendar_create(timezone, -1, I18N_ULOCALE_US, I18N_UCALENDAR_DEFAULT, &amp;ucalendar);
 </pre></li>
@@ -476,22 +479,24 @@ i18n_udatepg_create(I18N_ULOCALE_UK, &amp;udatepg);
 <p>To generate a date best pattern, use the <span style="font-family: Courier New,Courier,monospace">i18n_udatepg_get_best_pattern()</span> function. Prepare a draft format to define which kind of fields should be displayed (for example, E for the day of the week, M for month, y for year, d for the day of the month, and D for day of the year). As parameters, pass a handle to the date pattern generator, a format draft, the length of the draft (-1 if null-terminated), a buffer for the generated pattern, the size of the buffer, and a variable to store the actual size of the generated pattern.</p>
 <pre class="prettyprint">
 int pattern_len;
-i18n_uchar format[64];
-i18n_ustring_copy_ua_n(format, &quot;EEEdMMMyyyyHHmmssz&quot;, 64);
-i18n_uchar best_pattern[64];
-i18n_udatepg_get_best_pattern(udatepg, format, 64, best_pattern, 64, &amp;pattern_len);
+i18n_uchar format[BUF_SIZE];
+i18n_ustring_copy_ua_n(format, &quot;EEEdMMMyyyyHHmmssz&quot;, BUF_SIZE);
+i18n_uchar best_pattern[BUF_SIZE];
+i18n_udatepg_get_best_pattern(udatepg, format, BUF_SIZE, best_pattern, BUF_SIZE, &pattern_len);
 </pre>
 <p>To create a date format, use the <span style="font-family: Courier New,Courier,monospace">i18n_udate_create()</span> function. Specify the style to format time, the style to format date (from the <span style="font-family: Courier New,Courier,monospace">i18n_udate_format_style_e</span> enumeration, in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__BASE__UTILS__I18N__UDATE__MODULE.html#gaee2461e926bc151486d380c43bc4f2a3">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__BASE__UTILS__I18N__UDATE__MODULE.html#gaee2461e926bc151486d380c43bc4f2a3">wearable</a> applications), the desired locale, the desired time zone name, the length of the time zone name, a date pattern to use, the length of the pattern, and a handle to the created date format).</p>
 <pre class="prettyprint">
 i18n_udate_format_h date_format;
-i18n_ustring_copy_ua_n(timezone, &quot;Asia/Seoul&quot;, 17);
+const char *timezone_name = &quot;Asia/Seoul&quot;;
+int timezone_name_len = strlen(timezone_name);
+i18n_ustring_copy_ua_n(timezone, timezone_name, timezone_name_len+1);
 i18n_udate_create(I18N_UDATE_FULL, I18N_UDATE_FULL, I18N_ULOCALE_UK, timezone, -1, best_pattern, -1, &amp;date_format);
 </pre>
 <p>To obtain a well-formatted Ustring with a specified date, use the <span style="font-family: Courier New,Courier,monospace">i18n_udate_format_date()</span> function. The parameters are a handle to the date format, the date in milliseconds from the epoch, a buffer for a result, the size of the destination buffer, an optional handle to a UFieldPosition structure to get the positions of the fields, and a variable to store the actual size of the obtained Ustring.</p>
 <pre class="prettyprint">
-i18n_uchar date_result[64];
+i18n_uchar date_result[BUF_SIZE];
 int date_len;
-i18n_udate_format_date(date_format, now, date_result, 64, NULL, &amp;date_len);
+i18n_udate_format_date(date_format, now, date_result, BUF_SIZE, NULL, &amp;date_len);
 </pre></li>
 
 <li>Destroy the Ucalendar, Udatepg, and Udate.
@@ -522,9 +527,9 @@ i18n_udate_destroy(date_format);
        <li>Variable to store the actual length of the language code</li>
 </ul>
 <pre class="prettyprint">
-char language[BUFLEN];
+char language[BUF_SIZE];
 int lang_len;
-i18n_ulocale_get_language(I18N_ULOCALE_GERMANY, language, BUFLEN, &amp;lang_len);
+i18n_ulocale_get_language(I18N_ULOCALE_GERMANY, language, BUF_SIZE, &amp;lang_len);
 </pre></li>
 
 <li>To get the language ISO-3 code for the specified locale, use the <span style="font-family: Courier New,Courier,monospace">i18n_ulocale_get_language()</span> function. The parameter is the locale.
@@ -543,9 +548,9 @@ const char *language_iso = i18n_ulocale_get_iso3_language(I18N_ULOCALE_GERMANY);
 </ul>
 <pre class="prettyprint">
 char *locale = I18N_ULOCALE_CANADA_FRENCH;
-i18n_uchar language_name[BUFLEN];
+i18n_uchar language_name[BUF_SIZE];
 int lang_len;
-i18n_ulocale_get_display_language(locale, I18N_ULOCALE_GERMANY, language_name, BUFLEN, &amp;lang_len);
+i18n_ulocale_get_display_language(locale, I18N_ULOCALE_GERMANY, language_name, BUF_SIZE, &amp;lang_len);
 </pre>
 <p>In this example, the name of the &quot;fr_CA&quot; locale is obtained in German.</p></li>
 
@@ -555,7 +560,7 @@ i18n_ulocale_get_display_language(locale, I18N_ULOCALE_GERMANY, language_name, B
        <li>Variable to store the returned orientation</li>
 </ul>
 <pre class="prettyprint">
-char *locale = I18N_ULOCALE_ENGLISH;
+const char *locale = I18N_ULOCALE_ENGLISH;
 i18n_ulocale_layout_type_e type;
 i18n_ulocale_get_line_orientation(locale, &amp;type);
 </pre></li>
@@ -566,7 +571,7 @@ i18n_ulocale_get_line_orientation(locale, &amp;type);
        <li>Variable to store the returned orientation</li>
 </ul>
 <pre class="prettyprint">
-char *locale = I18N_ULOCALE_ENGLISH;
+const char *locale = I18N_ULOCALE_ENGLISH;
 i18n_ulocale_layout_type_e type;
 i18n_ulocale_get_character_orientation(locale, &amp;type);
 </pre></li>
@@ -578,9 +583,9 @@ i18n_ulocale_get_character_orientation(locale, &amp;type);
        <li>Size of the buffer</li>
 </ul>
 <pre class="prettyprint">
-char *locale = I18N_ULOCALE_ENGLISH;
-char *variant = malloc(sizeof(char) * BUFLEN);
-int32_t variant_len = i18n_ulocale_get_variant(locale, variant, BUFLEN);
+const char *locale = I18N_ULOCALE_ENGLISH;
+char *variant = malloc(sizeof(char) * BUF_SIZE);
+int32_t variant_len = i18n_ulocale_get_variant(locale, variant, BUF_SIZE);
 </pre>
 <p>The function returns the actual size of the variant.</p>
 </li>
@@ -595,9 +600,9 @@ int32_t variant_len = i18n_ulocale_get_variant(locale, variant, BUFLEN);
 </ul>
 
 <pre class="prettyprint">
-i18n_uchar name[BUFLEN];
+i18n_uchar name[BUF_SIZE];
 int name_len;
-i18n_ulocale_get_display_name(I18N_ULOCALE_CANADA_FRENCH, I18N_ULOCALE_GERMANY, name, BUFLEN, &amp;name_len);
+i18n_ulocale_get_display_name(I18N_ULOCALE_CANADA_FRENCH, I18N_ULOCALE_GERMANY, name, BUF_SIZE, &amp;name_len);
 </pre>
 <p>In this example, the name of the &quot;fr_CA&quot; locale is obtained in German.</p></li>
 
@@ -626,9 +631,9 @@ i18n_ulocale_set_default(I18N_ULOCALE_KOREA);</pre></li>
 <ul>
        <li>Number format style (such as <span style="font-family: Courier New,Courier,monospace">I18N_UNUMBER_CURRENCY</span>; see the <span style="font-family: Courier New,Courier,monospace">i18n_unumber_format_style_e</span> enumeration, in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__BASE__UTILS__I18N__UNUMBER__MODULE.html#ga4edc8cb72e7f46e05d8cdfe24cf386f1">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__BASE__UTILS__I18N__UNUMBER__MODULE.html#ga4edc8cb72e7f46e05d8cdfe24cf386f1">wearable</a> applications)</li>
        <li>Format pattern (only for decimal and rule-based types)</li>
-       <li>Length of the format pattern</li>
+       <li>Length of the format pattern, otherwise -1 if NULL-terminated. This argument is ignored unless the style is I18N_UNUMBER_PATTERN_*</li>
        <li>Locale identifier (<span style="font-family: Courier New,Courier,monospace">NULL</span> for default)
-       <p>Some identifiers (string shortcuts for specific locales) are defined in the <span style="font-family: Courier New,Courier,monospace">utils_i18n_types.h</span> header file. For example, <span style="font-family: Courier New,Courier,monospace">I18N_ULOCALE_US</span> is equal to <span style="font-family: Courier New,Courier,monospace">&quot;en_US&quot;</span>.</p></li>
+       <p>Some identifiers (string shortcuts for specific locales) are defined in the <span style="font-family: Courier New,Courier,monospace">utils_i18n_types.h</span> header file. For example, <span style="font-family: Courier New,Courier,monospace">I18N_ULOCALE_US</span> is equal to <span style="font-family: Courier New,Courier,monospace">&quot;en_US&quot;</span></p></li>
        <li>Optional pointer to an <span style="font-family: Courier New,Courier,monospace">i18n_uparse_error_s</span> struct</li>
        <li>Handle to the created number format</li>
 </ul>
@@ -644,10 +649,10 @@ i18n_unumber_create(format_style, NULL, -1, locale, NULL, &amp;num_format);
 
 <p>After creating the number format, you can use it to format a given number based on the rules of a specified locale:</p>
 <pre class="prettyprint">
-#define BUFLEN 64
-i18n_uchar myString[BUFLEN];
+#define BUF_SIZE 64
+i18n_uchar myString[BUF_SIZE];
 double myNumber = 4.5;
-i18n_unumber_format_double(num_format, myNumber, myString, BUFLEN, NULL);
+i18n_unumber_format_double(num_format, myNumber, myString, BUF_SIZE, NULL);
 </pre>
 
 <p>The result set in the <span style="font-family: Courier New,Courier,monospace">myString</span> variable is equal to:</p>
@@ -665,10 +670,10 @@ $4.50
        <li>Variable to store the length of the symbol</li>
 </ul>
 <pre class="prettyprint">
-i18n_uchar buffer[BUFLEN];
+i18n_uchar buffer[BUF_SIZE];
 int buf_len;
 i18n_unumber_format_symbol_e symbol = I18N_UNUMBER_CURRENCY_SYMBOL;
-i18n_unumber_get_symbol(num_format, symbol, buffer, BUFLEN, &amp;buf_len);
+i18n_unumber_get_symbol(num_format, symbol, buffer, BUF_SIZE, &amp;buf_len);
 </pre>
 <p>The function returns only the symbol used in the given locale, in this example, the currency <span style="font-family: Courier New,Courier,monospace">$</span> sign.</p>
 </li>
@@ -692,10 +697,11 @@ i18n_unumber_get_symbol(num_format, symbol, buffer, BUFLEN, &amp;buf_len);
 <p>To start using the Ubrk library, create an iterator using the <span style="font-family: Courier New,Courier,monospace">i18n_ubrk_create()</span> function. Specify its parameters, which are the type of the iterator (use the <span style="font-family: Courier New,Courier,monospace">I18N_UBRK_WORD</span> word, <span style="font-family: Courier New,Courier,monospace">I18N_UBRK_CHARACTER</span> character, <span style="font-family: Courier New,Courier,monospace">I18N_UBRK_LINE</span> line, or <span style="font-family: Courier New,Courier,monospace">I18N_UBRK_SENTENCE</span> sentence iteration), the locale, string to iterate through, length of the string, and a handle to the created iterator.</p>
 <pre class="prettyprint">
 i18n_ubreak_iterator_h boundary;
-const char *str = &quot;Twinkle, twinkle little star&quot;
-i18n_uchar* stringToExamine = malloc(sizeof(i18n_uchar)*28);
+const char *str = &quot;Twinkle, twinkle little star&quot;;
+int str_len = strlen(str);
+i18n_uchar* stringToExamine = malloc(sizeof(i18n_uchar)*(str_len+1));
 i18n_ustring_copy_ua(stringToExamine, str);
-i18n_ubrk_create(I18N_UBRK_WORD, &quot;en_US&quot;, stringToExamine, i18n_ustring_get_length(stringToExamine), &amp;boundary);
+i18n_ubrk_create(I18N_UBRK_WORD, I18N_ULOCALE_US, stringToExamine, -1, &amp;boundary);
 </pre></li>
 
 <li><p>Change the position of the iterator.</p>
@@ -917,9 +923,9 @@ i18n_timezone_get_raw_offset(tmz, &amp;offset_milliseconds/MS_TO_MIN);
 
 <li><p>To get the region code associated with the time zone ID:</p>
 <pre class="prettyprint">
-char region[6];
+char region[BUF_SIZE];
 int32_t region_len = -1;
-i18n_timezone_get_region(timezone_id, region, &amp;region_len, 20);
+i18n_timezone_get_region(timezone_id, region, &amp;region_len, BUF_SIZE);
 </pre></li></ul></li>
 
 <li><p>Destroy the time zone when it is no longer needed:</p>
@@ -954,7 +960,7 @@ i18n_uset_create_empty(&amp;set);
 <li>Add characters from a string to the set:
 <pre class="prettyprint">
 const char *text = &quot;Example string&quot;;
-i18n_uchar u_input_text[BUFLEN];
+i18n_uchar u_input_text[BUF_SIZE];
 i18n_ustring_copy_ua(u_input_text, text);
 
 i18n_uset_add_all_code_points(set, u_input_text, -1);
@@ -989,6 +995,7 @@ i18n_ubool contains_character = i18n_uset_contains_range(set, &#39;a&#39;, &#39;
 <li>Check whether the set contains characters from another set:
 <pre class="prettyprint">
 i18n_uset_h compare_set = NULL;
+i18n_uset_create_empty(&compare_set);
 
 // Fill the second set
 i18n_ubool contains_character = i18n_uset_contains_all(set, compare_set);
@@ -1004,7 +1011,7 @@ i18n_ubool contains_character = i18n_uset_contains_all(set, compare_set);
 <li>Add a string to the set:
 <pre class="prettyprint">
 const char *text = &quot;Example string&quot;;
-i18n_uchar u_input_text[BUFLEN];
+i18n_uchar u_input_text[BUF_SIZE];
 i18n_ustring_copy_ua(u_input_text, text);
  
 i18n_uset_add_string(set, u_input_text, -1);
@@ -1032,6 +1039,10 @@ for (i = 0; i &lt; strings_count; ++i)
 </li>
 <li>Check whether the set contains a string:
 <pre class="prettyprint">
+const char *input_string = "Input string";
+int input_string_len = strlen(input_string);
+i18n_uchar *input_ustring = malloc(sizeof(i18n_uchar) * (input_string_len+1));
+i18n_ustring_copy_ua(input_ustring, input_string);
 i18n_ubool contains = i18n_uset_contains_string(set, input_ustring, -1);
 </pre>
 </li>