From: Jozef Marek Date: Fri, 7 Aug 2015 14:26:12 +0000 (+0200) Subject: [Tutorial][Base-Utils] Uset: add characters scenario X-Git-Tag: tizen_3.0/TD_SYNC/20161201~611^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50c99acd9fb09070d0146e81eb1c849daa2d3bae;p=sdk%2Fonline-doc.git [Tutorial][Base-Utils] Uset: add characters scenario Change-Id: I1b77b6fe9ea1fa338543bd033fc79cc5ec24e4eb Signed-off-by: Jozef Marek --- diff --git a/org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm b/org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm index 84f8787..79be505 100644 --- a/org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/base/i18n_tutorial_n.htm @@ -30,6 +30,7 @@
  • Managing Iteration Using Ubrk
  • Managing Enumerations
  • Managing Timezones
  • +
  • Managing Sets
  • Related Info

    - + @@ -45,17 +46,17 @@

    i18n: Managing Characters, Numbers, and Locales

    -

    This tutorial demonstrates how you can manage numbers, date, time and locale information.

    +

    This tutorial demonstrates how you can manage numbers, date, time and locale information.

    Warm-up

    -

    Become familiar with the i18n API basics by learning about:

    +

    Become familiar with the i18n API basics by learning about:

    Managing Characters and Strings

    - - - - - - +
    Note
    + + + + + - - + + +
    Note
    • All source and destination buffers must be different.
    • To use the localization-related features of the i18n API (in mobile and wearable applications), include the <utils_i18n.h> header file in your application:
       #include <utils_i18n.h>
      -

    Comparing Ustrings

    @@ -141,7 +143,7 @@ i18n_ucollator_str_collator(coll, s1, -1, s2, -1, &result);

    When you finish using the Ucollator, destroy it using the i18n_ucollator_destroy() function.

     i18n_ucollator_destroy(coll);
    -
    +

    Converting Strings to Ustrings

    To convert strings to Ustrings:

    @@ -590,7 +592,7 @@ const char *str = "USD"; i18n_unumber_set_symbol(num_format, I18N_UNUMBER_INTL_CURRENCY_SYMBOL, i18n_ustring_copy_ua(buffer, str), 3);
  • Get a locale associated with the number format. -

    To get a locale associated with the created number format, use the i18n_unumber_get_locale_by_type() function. The parameters are:

    +

    To get a locale associated with the created number format, use the i18n_unumber_get_locale_by_type() function. The parameters are:

    • Number format
    • Type of locale to get (see the i18n_ulocale_data_locale_type_e enumeration in documentation)
    • @@ -828,7 +830,6 @@ int32_t dst_savings; i18n_timezone_get_dst_savings(tmz, &dst_savings);

      The result is returned in milliseconds (3600000 ms = 1 hour).

      -
    • To get the raw GMT offset:

       int32_t offset_milliseconds;
      @@ -849,6 +850,70 @@ i18n_timezone_destroy(tmz);
       
    • +

      Managing Sets

      +

      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.

      + +

      To use Uset API (in mobile and wearable applications), include the <utils_i18n.h> header file in your application.

      +
    • +The first step is to create a set. The code below creates an empty set: +
      +i18n_uset_h set;
      +i18n_uset_create_empty(&set);
      +
      +
    • + +

      Managing characters

      +

      The set can contain characters as its elements. It's also possible to check if a set contains specified characters.

      +
        +
      1. +Add characters from a string to the set: +
        +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);
        +
        +
      2. + +
      3. +Get the list of characters in the set: +
        +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);
        +}
        +
        +
      4. + +
      5. +Check whether the set contains the given character: +
        +i18n_ubool contains_character = i18n_uset_contains(set, 'a');
        +
        +
      6. + +
      7. +Check whether the set contains characters from the a - c range: +
        +i18n_ubool contains_character = i18n_uset_contains_range(set, 'a', 'c');
        +
        +
      8. + +
      9. +Check whether the set contains characters from another set: +
        +i18n_uset_h compare_set = NULL;
        +// Fill the second set
        +i18n_ubool contains_character = i18n_uset_contains_all(set, compare_set);
        +
        +
      10. + + +