summaryrefslogtreecommitdiff
path: root/src/util/util.c
diff options
context:
space:
mode:
authorKyuho Jo <kyuho.jo@samsung.com>2016-03-23 14:35:03 +0900
committerKyuho Jo <kyuho.jo@samsung.com>2016-03-23 14:35:03 +0900
commitcbf881c56718003d8306d01ca56b1b4092ca7d57 (patch)
tree1470df861838eb6665da225eeeff02cb41b6d683 /src/util/util.c
parent656e5b2644786a48d00930c159e93e912a10132f (diff)
downloadair_mediahub-cbf881c56718003d8306d01ca56b1b4092ca7d57.tar.gz
air_mediahub-cbf881c56718003d8306d01ca56b1b4092ca7d57.tar.bz2
air_mediahub-cbf881c56718003d8306d01ca56b1b4092ca7d57.zip
Replace repeated codes with functions
Change-Id: If73e66c73307df020d2d7acda2e37dd58fd94c12 Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
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;
+}