From: Tomasz Bochenski Date: Fri, 20 Oct 2017 10:51:49 +0000 (+0200) Subject: [Base-utils] i18n Parse Position doc X-Git-Tag: MD/guides-dotnet~18^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F87%2F156887%2F4;p=sdk%2Fonline-doc.git [Base-utils] i18n Parse Position doc PS2: Reviewed PS3: Rebase PS4: Fixed rebasing Change-Id: I9977bde53baece73e5a057f33611f2eae866e520 Signed-off-by: Tomasz Bochenski --- diff --git a/org.tizen.guides/html/native/internationalization/i18n_n.htm b/org.tizen.guides/html/native/internationalization/i18n_n.htm index dd3f45c..c40a7c9 100644 --- a/org.tizen.guides/html/native/internationalization/i18n_n.htm +++ b/org.tizen.guides/html/native/internationalization/i18n_n.htm @@ -1,4 +1,4 @@ - + @@ -46,6 +46,7 @@
  • Field Identification in Formatted Output
  • String Format Management
  • Measurement Values with Units
  • +
  • Parse Position Tracking
  • Time Scale Conversion with Utmscale
  • String Iteration with UCharIter
  • Prerequisites
  • @@ -61,6 +62,7 @@
  • Managing the Field Position
  • Managing String Formatting
  • Managing Measure Objects
  • +
  • Managing the Parse Position
  • Converting Time Scales
  • Retrieving the ICU Version
  • Iterating through Strings
  • @@ -103,18 +105,19 @@

    You can use the Format functions to manage the string representations of objects or values.

  • Managing measurement values with units

    You can store numeric measurement values with various units.

  • +
  • Tracking the parsing position +

    You can track the current position while parsing with ParsePosition.

  • Converting time scales

    You can convert datetimes between time scales with Utmscale.

  • Retrieving the ICU version

    You can retrieve the currently-used version of the ICU library with Uversion.

  • Iterating through strings -

    You can iterate through strings, in a safe way, with UCharIter.

    -
  • +

    You can iterate through strings, in a safe way, with UCharIter.

    Note - The Alphabetic Index, FieldPosition, Format, Measure, and Utmscale APIs are supported since Tizen 3.0. The Uversion and UCharIter APIs are supported since Tizen 4.0. + The Alphabetic Index, FieldPosition, Format, Formattable, Measure, MeasureUnit, ParsePosition, and Utmscale APIs are supported since Tizen 3.0. The Uversion and UCharIter APIs are supported since Tizen 4.0.

    Location Boundaries with Ubrk

    @@ -360,7 +363,7 @@
  • newLanguage + newCountry + newVariant

    A valid ISO language code, ISO country code, and additional information on the variant. The variant codes are vendor and browser-specific. For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. Where there are 2 variants, separate them with an underscore, and put the most important one first. For example, a Traditional Spanish collation might be referenced, with ES, ES, Traditional_WIN.

  • - +

    @@ -712,7 +715,7 @@ The measure objects can be formatted using the MeasureFormat API (in Temperature - degree Celcius + degree Celsius °C @@ -1111,6 +1114,11 @@ The measure objects can be formatted using the MeasureFormat API (in Parse Position Tracking +

    The ParsePosition API (in mobile and wearable applications) is used by the Format API (in mobile and wearable applications) and the MeasureFormat API (in mobile and wearable applications) API to track the current position while parsing.

    +

    The xxx_parse_object() functions require a parse position pointer as an argument. By design, you can use the same parse position pointer as you parse through a string with various formats, since the index parameter records the current position.

    + +

    Time Scale Conversion with Utmscale

    The Utmscale API (in mobile and wearable applications) allows you to convert between time scales.

    There are various conventions for binary datetime, depending on the platform and protocol. Some of these have severe drawbacks. For example, 32-bit Unix time (seconds since Jan 1, 1970) cannot support datetimes beyond the beginning of the year 2038. Arithmetic manipulations can also cause serious problems. For example, when calculating the average of 2 datetimes, if you calculate them with average_time = (time1 + time2)/2, there can be overflow even with dates around the present. Additionally, there is the issue of converting between different systems.

    @@ -2578,7 +2586,7 @@ int32_t index = 10; /* Index set after 10th character in source string */ i18n_parse_position_create_with_index(index, &parse_position); /* Parses from 10th character to next space character */ -i18n_format_parse_object_with_parse_position(format, source, parse_position, &result); +i18n_format_parse_object_with_parse_position(format, source, parse_position, &result); i18n_parse_position_destroy(parse_position); double value = 0; @@ -2710,7 +2718,7 @@ i18n_measure_destroy(measure);

    Managing Measurement Units

    -

    You can use the MeasureUnit API (in mobile and wearable applications) to create measure unit objects, which can be passed to the Measure or MeasureFormat (in mobile and wearable applications) APIs.

    +

    You can use the MeasureUnit API (in mobile and wearable applications) to create measure unit objects, which can be passed to the Measure or MeasureFormat (in mobile and wearable applications) APIs.

    1. To create a liter unit object:
      @@ -2743,7 +2751,7 @@ int32_t max = 20;
       i18n_measure_unit_h array[20];
       int32_t available;
       
      -i18n_measure_unit_get_available(max, &array, &available); 
      +i18n_measure_unit_get_available(max, &array, &available);
       
    2. To retrieve the available units for a specific measure:
      @@ -2783,6 +2791,84 @@ i18n_measure_unit_destroy(unit);
       
    + +

    Managing the Parse Position

    +

    Since Tizen 3.0, you can use the ParsePosition API (in mobile and wearable applications) to track the current position while parsing.

    +

    To manage the parse position:

    +
      +
    1. +To create a parse position object: +
        +
      • +Without specifying a position index: +
        +i18n_parse_position_h parse_position;
        +i18n_parse_position_create(&parse_position);
        +
        +
      • +
      • +At a specific position index: +
        +i18n_parse_position_h parse_position;
        +i18n_parse_position_create_with_index(new_text_offset, &parse_position);
        +
        +
      • +
      +
    2. +
    3. +To clone a parse position pointer: +
      +i18n_parse_position_h parse_position_clone;
      +i18n_parse_position_clone(parse_position, &parse_position_clone);
      +
      +
    4. +
    5. +To manage the parse position index: +
        +
      • +To set the index: +
        +int32_t parse_position_index = 4;
        +i18n_parse_position_set_index(parse_position, parse_position_index);
        +
        +
      • +
      • +To retrieve the index: +
        +int32_t parse_position_index;
        +i18n_parse_position_get_index(parse_position, &parse_position_index);
        +
        +
      • +
      +
    6. +
    7. +To calculate the parsed length: +
      +i18n_format_h num_format;
      +i18n_uparse_error_s parse_err;
      +i18n_unumber_create(I18N_UNUMBER_PERCENT, NULL, -1, I18N_ULOCALE_US, &parse_err, &num_format);
      +
      +i18n_parse_position_h parse position;
      +i18n_parse_position_create_with_index(3, &parse_position);
      +
      +i18n_formattable_h result;
      +char* text_to_parse = "1234567%";
      +int32_t begin;
      +int32_t end;
      +i18n_parse_position_get_index(parse_position, &begin);
      +i18n_format_parse_object_with_parse_position(num_format, text_to_parse, parse_position, &result);
      +i18n_parse_position_get_index(parse_position, &end);
      +
      +int length = end - begin;
      +
      +
    8. +
    9. +When it is no longer needed, destroy the parse position object: +
      +i18n_parse_position_destroy(parse_position);
      +
      +
    10. +

    Converting Time Scales

    Since Tizen 3.0, you can use the Utmscale API (in mobile and wearable applications) to convert binary datetimes between various platform-dependent time scales.

    To convert a datetime value: