* <td>formatMeasurePerUnit</td>
* </tr>
* <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULE</td>
+ * <td>#i18n_measure_format_get_unit_display_name</td>
+ * <td>getUnitDisplayName</td>
+ * </tr>
+ * <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
* <td>#i18n_field_position_create</td>
* <td>FieldPosition</td>
i18n_uchar *append_to,
int32_t *output_length);
+/**
+ * @brief Gets the display name of the #i18n_measure_unit_h corresponding to the current locale and format width.
+ * @since_tizen 5.0
+ *
+ * @param[in] measure_format The measure format object
+ * @param[in] measure_unit The unit for which to get the display name
+ * @param[in] buffer_size The size of the @a buffer.
+ * If <code>@a buffer_size <= 0</code> then the output string is not
+ * inserted to the @a buffer and #I18N_ERROR_BUFFER_OVERFLOW
+ * is returned.
+ * @param[out] buffer The buffer to which the formatted string will be inserted.
+ * Can be @c NULL if <code>@a output_buffer_size <= 0</code>.
+ * @param[out] output_length The length of the output string
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_BUFFER_OVERFLOW Buffer overflow
+ */
+int i18n_measure_format_get_unit_display_name(const i18n_measure_format_h measure_format,
+ const i18n_measure_unit_h measure_unit,
+ int32_t buffer_size,
+ i18n_uchar *buffer,
+ int32_t *output_length);
/**
* @}
return _i18n_error_mapping(status);
}
+int i18n_measure_format_get_unit_display_name(const i18n_measure_format_h measure_format,
+ const i18n_measure_unit_h measure_unit,
+ int32_t buffer_size,
+ i18n_uchar *buffer,
+ int32_t *output_length)
+{
+ retv_if(measure_format == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(measure_unit == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(output_length == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+ UnicodeString result = ((MeasureFormat *)measure_format)->getUnitDisplayName(*((MeasureUnit *)measure_unit), status);
+ if (result == NULL) {
+ *output_length = 0;
+ return I18N_ERROR_NONE;
+ }
+
+ const i18n_uchar *uchar_result = (i18n_uchar *)result.getTerminatedBuffer();
+
+ retv_if(uchar_result == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *output_length = i18n_ustring_get_length(uchar_result);
+ retv_if(*output_length > buffer_size, I18N_ERROR_BUFFER_OVERFLOW);
+
+ if (*output_length > 0)
+ i18n_ustring_copy_n(buffer, uchar_result, buffer_size);
+
+ return _i18n_error_mapping(status);
+}
+