summaryrefslogtreecommitdiff
path: root/src/util/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/util.c')
-rw-r--r--src/util/util.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c
index 9ce3081..cb84c9e 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -455,3 +455,61 @@ Elm_Image_Orient util_get_orient(media_content_orientation_e orient)
return o;
}
+
+i18n_uchar* util_convert_to_UTF16_string(const char *source_string)
+{
+ int buffer_length = 0;
+ i18n_error_code_e error_from_i18n;
+ i18n_uchar *converted_string = NULL;
+
+ /* Calc buffer size for converted UTF16 string */
+ i18n_ustring_from_UTF8(NULL, 0, &buffer_length, source_string, -1, &error_from_i18n);
+
+ converted_string = malloc((buffer_length + 2) * sizeof(i18n_uchar));
+ if (converted_string == NULL) {
+ _ERR("malloc failed");
+ goto OUT;
+ }
+
+ /* Convert to i18n(UTF16) string */
+ i18n_ustring_from_UTF8(converted_string, buffer_length + 1, &buffer_length, source_string, -1, &error_from_i18n);
+ if (error_from_i18n != I18N_ERROR_NONE) {
+ _ERR("i18n_ustring_from_UTF8 returns [%d]", error_from_i18n);
+ free(converted_string);
+ goto OUT;
+ }
+ converted_string[buffer_length] = (i18n_uchar)0;
+
+OUT:
+
+ return converted_string;
+}
+
+char* util_convert_to_UTF8_string(i18n_uchar *sourct_string)
+{
+ int buffer_length = 0;
+ i18n_error_code_e error_from_i18n;
+ char *converted_string = NULL;
+
+ i18n_ustring_to_UTF8(NULL, 0, &buffer_length, sourct_string, -1, &error_from_i18n);
+
+ converted_string = malloc((buffer_length + 2) * sizeof(char));
+ if (converted_string == NULL) {
+ _ERR("malloc failed");
+ goto OUT;
+ }
+
+ /* Convert to UTF8 */
+ i18n_ustring_to_UTF8(converted_string, buffer_length + 1, &buffer_length, sourct_string, -1, &error_from_i18n);
+ if (error_from_i18n != I18N_ERROR_NONE) {
+ _ERR("i18n_ustring_to_UTF8 returns [%d]", error_from_i18n);
+ free(converted_string);
+ converted_string = NULL;
+ goto OUT;
+ }
+ converted_string[buffer_length] = '\0';
+
+OUT:
+
+ return converted_string;
+}