Name: capi-base-utils
Summary: Base Utils
-Version: 1.0.0
+Version: 1.0.1
Release: 1
Group: Base
License: Apache-2.0 and ICU
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE</td>
- * <td>Udate module consists of functions that convert dates and times from their
+ * <td>Udate module consists of functions that convert dates and times from their
internal representations to textual form and back again in a language-independent manner.</td>
* </tr>
* <tr>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
- * <td>#i18n_timezone_in_daylight_time</td>
- * <td>inDaylightTime</td>
- * </tr>
- * <tr>
- * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
* <td>#i18n_timezone_has_same_rule</td>
* <td>hasSameRules</td>
* </tr>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE</td>
- * <td>#i18n_usearch_create</td>
+ * <td>#i18n_usearch_create_new</td>
* <td>usearch_open</td>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td>
* <td>#i18n_ustring_r_string</td>
* <td>u_strrstr</td>
- * </tr>
+ * </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td>
* <td>#i18n_ustring_find_last</td>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td>
- * <td>#i18n_ustring_to_title</td>
+ * <td>#i18n_ustring_to_title_new</td>
* <td>u_strToTitle</td>
* </tr>
* <tr>
* </tr>
* </table>
*/
-
+
#ifdef __cplusplus
}
#endif
* @param[in] timezone_id The system time zone ID.
* @param[out] region Output buffer for receiving the region code.
* @param[out] region_len The length of the region code.
- * @param[in] region_capacity The size of the output buffer.
+ * @param[in] region_capacity The size of the output buffer. If it is lower than required @a region buffer size,
+ * then I18N_ERROR_BUFFER_OVERFLOW error is returned.
*
* @return the version string, such as "2007f"
*/
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] timezone The i18n_timezone_h to get a display name.
- * @param[in] language The language in which to supply the display name.
- * @param[in] country The country in which to supply the display name.
+ * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale.
+ * @param[in] country The country in which to supply the display name. This parameter can be NULL.
* @param[out] display_name The human-readable name of this time zone in the default locale.
*
* @retval #I18N_ERROR_NONE Successful
* @param[in] timezone The i18n_timezone_h to get a display name.
* @param[in] daylight If true, display_name is filled with the daylight savings name.
* @param[in] style The style displayed on.
- * @param[in] language The language in which to supply the display name.
- * @param[in] country The country in which to supply the display name.
+ * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale.
+ * @param[in] country The country in which to supply the display name. This parameter can be NULL.
* @param[out] display_name The human-readable name of this time zone in the default locale.
*
* @retval #I18N_ERROR_NONE Successful
I18N_WARNING_STRING_NOT_TERMINATED = TIZEN_ERROR_UTILITY_ICU | 0x1D, /**< String not terminated with NULL. @if MOBILE (Since 2.3.1) @endif*/
I18N_ERROR_STD3_ASCII_RULES = TIZEN_ERROR_UTILITY_ICU | 0x1E, /**< Argument does not satisfy STD3 rules. @if MOBILE (Since 2.3.1) @endif*/
I18N_ERROR_UNASSIGNED = TIZEN_ERROR_UTILITY_ICU | 0x1F, /**< Unassigned code points are found. @if MOBILE (Since 2.3.1) @endif*/
- I18N_WARNING_SORT_KEY_TOO_SHORT = -123, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/
+ I18N_WARNING_SORT_KEY_TOO_SHORT = TIZEN_ERROR_UTILITY_ICU | 0x20, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/
I18N_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error. @if MOBILE (Since 2.3.1) @endif*/
} i18n_error_code_e;
* #I18N_UBRK_LINE, #I18N_UBRK_SENTENCE
* @param[in] locale The locale specifying the text-breaking conventions.
* If @c NULL, the default locale will be used.
- * @param[in] text The text to be iterated over.
+ * @param[in] text The text to be iterated over. May be @c NULL, then the iterator will be created without any text.
+ * The text can be set later with i18n_ubrk_set_text() function.
* @param[in] text_length The number of characters in text, or -1 if NULL-terminated.
* @param[out] break_iter A pointer to the #i18n_ubreak_iterator_h for the specified locale.
* @return The obtained error code.
* algorithm of Unicode TR 21.\n
* The result may be longer or shorter than the original.
* The source string and the destination buffer are allowed to overlap.
- * @since_tizen MOBILE 2.3.1
+ * @since_tizen 2.3.1
*
* @param[out] dest A buffer for the result string.\n
* The result will be zero-terminated if the buffer is large enough.
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
- * <td>#i18n_ucalendar_is_in_daylight_time</td>
- * <td>inDaylightTime</td>
- * </tr>
- * <tr>
- * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
* <td>#i18n_timezone_has_same_rule</td>
* <td>hasSameRules</td>
* </tr>
* @param[in] timezone_id The system time zone ID.
* @param[out] region Output buffer for receiving the region code.
* @param[out] region_len The length of the region code.
- * @param[in] region_capacity The size of the output buffer.
+ * @param[in] region_capacity The size of the output buffer. If it is lower than required @a region buffer size,
+ * then I18N_ERROR_BUFFER_OVERFLOW error is returned.
*
* @return the version string, such as "2007f"
*/
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] timezone The i18n_timezone_h to get a display name.
- * @param[in] language The language in which to supply the display name.
- * @param[in] country The country in which to supply the display name.
+ * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale.
+ * @param[in] country The country in which to supply the display name. This parameter can be NULL.
* @param[out] display_name The human-readable name of this time zone in the default locale.
*
* @retval #I18N_ERROR_NONE Successful
* @param[in] timezone The i18n_timezone_h to get a display name.
* @param[in] daylight If true, display_name is filled with the daylight savings name.
* @param[in] style The style displayed on.
- * @param[in] language The language in which to supply the display name.
- * @param[in] country The country in which to supply the display name.
+ * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale.
+ * @param[in] country The country in which to supply the display name. This parameter can be NULL.
* @param[out] display_name The human-readable name of this time zone in the default locale.
*
* @retval #I18N_ERROR_NONE Successful
I18N_WARNING_STRING_NOT_TERMINATED = TIZEN_ERROR_UTILITY_ICU | 0x1D, /**< String not terminated with NULL. @if MOBILE (Since 2.3.1) @endif*/
I18N_ERROR_STD3_ASCII_RULES = TIZEN_ERROR_UTILITY_ICU | 0x1E, /**< Argument does not satisfy STD3 rules. @if MOBILE (Since 2.3.1) @endif*/
I18N_ERROR_UNASSIGNED = TIZEN_ERROR_UTILITY_ICU | 0x1F, /**< Unassigned code points are found. @if MOBILE (Since 2.3.1) @endif*/
- I18N_WARNING_SORT_KEY_TOO_SHORT = -123, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/
+ I18N_WARNING_SORT_KEY_TOO_SHORT = TIZEN_ERROR_UTILITY_ICU | 0x20, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/
I18N_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error. @if MOBILE (Since 2.3.1) @endif*/
} i18n_error_code_e;
* #I18N_UBRK_LINE, #I18N_UBRK_SENTENCE
* @param[in] locale The locale specifying the text-breaking conventions.
* If @c NULL, the default locale will be used.
- * @param[in] text The text to be iterated over.
+ * @param[in] text The text to be iterated over. May be @c NULL, then the iterator will be created without any text.
+ * The text can be set later with i18n_ubrk_set_text() function.
* @param[in] text_length The number of characters in text, or -1 if NULL-terminated.
* @param[out] break_iter A pointer to the #i18n_ubreak_iterator_h for the specified locale.
* @return The obtained error code.
dlog_print(DLOG_INFO, LOG_TAG, "%s %s %s\n", src, result == 1 ? "is equal to" : "is not equal to", target ); // tizen is not equal to bada
// destroys the collator
- i18n_ucollator_destroy( coll );
+ i18n_ucollator_destroy( coll );
* @endcode
* @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_SAMPLE_CODE_2 Sample Code 2
* @brief Sorts in ascending order on the given data using string_ucollator
for ( i = 0; i < sizeof( src ) / sizeof( src[0] ); i++ ) {
dlog_print(DLOG_INFO, LOG_TAG, "%s\n", src[i] );
} // ariplane banana cat
- * @endcode
+ * @endcode
*/
/**
*/
int i18n_ucollator_create ( const char *locale, i18n_ucollator_h *collator );
-/**
+/**
* @brief Closes a i18n_ucollator_h.
* @details Once closed, a string_ucollator_h should not be used. Every an open collator should be closed. Otherwise, a memory leak will result.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @brief Disposes of resources in use by the iterator.
* @details If @c enumeration is <code>NULL</code>, does nothing. After this call, any <code>char*</code> or <code>i18n_uchar*</code> returned
* by i18n_uenumeration_unext() or i18n_uenumeration_next() is invalid.
- * @remarks Error codes are described in Exceptions section.
+ * @remarks Error codes are described in #i18n_error_code_e description.
* @since_tizen 2.3.1
*
* @param[in] enumeration An #i18n_uenumeration_h to destroy
/**
* @brief Resets the iterator to the current list of service IDs.
* @details This re-establishes sync with the service and rewinds the iterator to start at the first element.
- * @remarks Error codes are described in Exceptions section and #i18n_error_code_e description.
+ * @remarks Error codes are described in #i18n_error_code_e description.
* @since_tizen 2.3.1
*
* @param[in] enumeration An #i18n_uenumeration_h
* @return The obtained error code.
* @retval #I18N_ERROR_NONE Successful
* @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- * @retval #I18N_ERROR_ENUM_OUT_OF_SYNC The iterator is out of sync
*/
int i18n_uenumeration_reset ( i18n_uenumeration_h enumeration );
* @brief Given an array of <code>const i18n_uchar*</code> strings, return an #i18n_uenumeration_h.
* @details String pointers from 0..count-1 must not be <code>NULL</code>.
* Do not free or modify either the string array or the characters it points to until this object has been destroyed with i18n_uenumeration_destroy().
- * @remarks Error codes are described in Exceptions section and #i18n_error_code_e description.
+ * @remarks Error codes are described in #i18n_error_code_e description.
* @since_tizen 2.3.1
*
* @param[in] strings An array of const <code>i18n_uchar*</code> strings (each null terminated). All storage is owned by the caller.
* @brief Given an array of <code>const char*</code> strings (invariant chars only), return an #i18n_uenumeration_h.
* @details String pointers from 0..count-1 must not be <code>NULL</code>.
* Do not free or modify either the string array or the characters it points to until this object has been destroyed with i18n_uenumeration_destroy().
- * @remarks Error codes are described in Exceptions section and #i18n_error_code_e description.
+ * @remarks Error codes are described in #i18n_error_code_e description.
* @since_tizen 2.3.1
*
* @param[in] strings A array of <code>char*</code> strings (each null terminated). All storage is owned by the caller.
int i18n_timezone_get_region(const char *timezone_id, char *region, int32_t *region_len, int32_t region_capacity)
{
- retv_if(timezone_id == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(timezone_id == NULL || region == NULL || region_len == NULL, I18N_ERROR_INVALID_PARAMETER);
+
UErrorCode status = U_ZERO_ERROR;
const UnicodeString id(timezone_id);
*region_len = TimeZone::getRegion(id, region, region_capacity, status);
int i18n_timezone_get_offset_with_date(i18n_timezone_h timezone, i18n_udate date, i18n_ubool local, int32_t *raw_offset, int32_t *dst_offset)
{
- retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(timezone == NULL || raw_offset == NULL || dst_offset == NULL, I18N_ERROR_INVALID_PARAMETER);
+
UErrorCode status = U_ZERO_ERROR;
((TimeZone*)timezone)->getOffset( date, local, *raw_offset, *dst_offset, status );
int i18n_timezone_get_raw_offset(i18n_timezone_h timezone, int32_t *offset_milliseconds)
{
- retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(timezone == NULL || offset_milliseconds == NULL, I18N_ERROR_INVALID_PARAMETER);
+
*offset_milliseconds = ((TimeZone*)timezone)->getRawOffset();
return I18N_ERROR_NONE;
set_last_result(I18N_ERROR_INVALID_PARAMETER);
return 0;
}
- i18n_error_code_e i18n_error;
- UErrorCode icu_error = U_ZERO_ERROR;
- int32_t result_ucal_getLimit = ucal_getLimit(calendar, field, type, &icu_error);
- ERR("ErrorCode : %d", icu_error);
- ERR_MAPPING(icu_error, i18n_error);
- set_last_result(i18n_error);
+
+ int32_t result_ucal_getLimit = 0;
+ switch (field) {
+ case I18N_UCALENDAR_YEAR_WOY:
+ case I18N_UCALENDAR_DOW_LOCAL:
+ case I18N_UCALENDAR_EXTENDED_YEAR:
+ case I18N_UCALENDAR_JULIAN_DAY:
+ case I18N_UCALENDAR_MILLISECONDS_IN_DAY:
+ case I18N_UCALENDAR_IS_LEAP_MONTH:
+ case I18N_UCALENDAR_FIELD_COUNT:
+ {
+ set_last_result(I18N_ERROR_INVALID_PARAMETER);
+ ERR("Unsupported filed");
+ break;
+ }
+ default:
+ {
+ i18n_error_code_e i18n_error = I18N_ERROR_NONE;
+ UErrorCode icu_error = U_ZERO_ERROR;
+ int32_t limit = ucal_getLimit(calendar, field, type, &icu_error);
+ ERR("ErrorCode : %d", icu_error);
+ ERR_MAPPING(icu_error, i18n_error);
+ set_last_result(i18n_error);
+ if(i18n_error == I18N_ERROR_NONE)
+ result_ucal_getLimit = limit;
+ }
+ }
+
return result_ucal_getLimit;
}
{
return I18N_ERROR_INVALID_PARAMETER;
}
- *date_field_type = (i18n_ucalendar_date_fields_e)udat_toCalendarDateField(field);
+
+ switch (field) {
+ case I18N_UDATE_FORMAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD:
+ case I18N_UDATE_FORMAT_TIMEZONE_ISO_FIELD:
+ case I18N_UDATE_FORMAT_TIMEZONE_ISO_LOCAL_FIELD:
+ case I18N_UDATE_FORMAT_FIELD_COUNT:
+ ERR("Unsupported filed");
+ return I18N_ERROR_INVALID_PARAMETER;
+ default:
+ *date_field_type = (i18n_ucalendar_date_fields_e)udat_toCalendarDateField(field);
+ }
+
return I18N_ERROR_NONE;
}
int i18n_udate_parse_calendar (const i18n_udate_format_h format, i18n_ucalendar_h * calendar, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos )
{
- if (format == NULL || calendar == NULL || text == NULL)
+ if (format == NULL || calendar == NULL || text == NULL || text_length < -1)
{
return I18N_ERROR_INVALID_PARAMETER;
}
int i18n_udate_get_calendar ( const i18n_udate_format_h format, i18n_ucalendar_h *calendar)
{
- if (format == NULL)
+ if (format == NULL || calendar == NULL)
{
return I18N_ERROR_INVALID_PARAMETER;
}
int i18n_udate_set_symbols ( i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, i18n_uchar *value, int32_t value_length )
{
- if (format == NULL)
+ if (format == NULL || symbol_index < 0)
{
return I18N_ERROR_INVALID_PARAMETER;
}
int32_t i18n_ulocale_get_country (const char *locale_id, char *country, int32_t country_capacity, int *error)
{
- int32_t result = uloc_getCountry(locale_id, country, country_capacity, error);
- *error = _i18n_error_mapping(*error);
+ if(NULL == country) {
+ if(NULL != error) {
+ *error = I18N_ERROR_INVALID_PARAMETER;
+ }
+ return 0;
+ }
+
+ UErrorCode icu_error = U_ZERO_ERROR;
+ int32_t result = uloc_getCountry(locale_id, country, country_capacity, &icu_error);
+ if(NULL != error) {
+ *error = _i18n_error_mapping(icu_error);
+ }
return result;
}
int32_t i18n_ulocale_get_keyword_value (const char *locale_id, const char *keyword_name, char *buffer,
int32_t buffer_capacity)
{
- if(NULL == keyword_name || NULL == buffer || buffer_capacity < 0){
+ if(NULL == locale_id || NULL == keyword_name || NULL == buffer || buffer_capacity < 0){
set_last_result(I18N_ERROR_INVALID_PARAMETER);
return -1;
}
int i18n_unumber_get_symbol (const i18n_unumber_format_h fmt, i18n_unumber_format_symbol_e symbol, i18n_uchar *buffer, int32_t size, int32_t *len_symbol)
{
- retv_if(fmt == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(fmt == NULL || len_symbol == NULL, I18N_ERROR_INVALID_PARAMETER);
UErrorCode icu_error = U_ZERO_ERROR;
*len_symbol = unum_getSymbol(fmt, symbol, buffer, size, &icu_error);
int32_t i18n_unumber_format_decimal (const i18n_unumber_format_h fmt, const char *number, int32_t length, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos)
{
- if(fmt == NULL) {
+ if(fmt == NULL || number == NULL) {
set_last_result(I18N_ERROR_INVALID_PARAMETER);
return 0;
}
double i18n_unumber_parse_double_currency (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, i18n_uchar *currency)
{
- if(fmt == NULL || text == NULL) {
+ if(fmt == NULL || text == NULL || currency == NULL) {
set_last_result(I18N_ERROR_INVALID_PARAMETER);
return 0;
}
int i18n_unumber_apply_pattern (i18n_unumber_format_h format, i18n_ubool localized, const i18n_uchar *pattern, int32_t pattern_length, i18n_uparse_error_s* parse_error)
{
- if(format == NULL) {
+ if(format == NULL || pattern == NULL || pattern_length < -1) {
return I18N_ERROR_INVALID_PARAMETER;
}
int i18n_uset_clone ( const i18n_uset_h set, i18n_uset_h *set_clone )
{
set_last_result(I18N_ERROR_NONE);
- if (set == NULL) {
+ if (set == NULL || set_clone == NULL) {
return I18N_ERROR_INVALID_PARAMETER;
}
*set_clone = (i18n_uset_h)uset_clone((const USet*)set);
int i18n_uset_clone_as_thawed ( const i18n_uset_h set, i18n_uset_h *set_copy )
{
set_last_result(I18N_ERROR_NONE);
- if (set == NULL) {
+ if (set == NULL || set_copy == NULL) {
return I18N_ERROR_INVALID_PARAMETER;
}
*set_copy = (i18n_uset_h)uset_cloneAsThawed((const USet*)set);
int32_t i18n_uset_get_item ( const i18n_uset_h set, int32_t item_index, i18n_uchar32 *start, i18n_uchar32 *end,
i18n_uchar *str, int32_t str_capacity )
{
- if (set == NULL || (item_index < 0 || item_index > uset_getItemCount((const USet*)set)-1)) {
+ if (set == NULL || (item_index < 0 || item_index > uset_getItemCount((const USet*)set)-1) || start == NULL || end == NULL) {
set_last_result(I18N_ERROR_INVALID_PARAMETER);
return 0;
}