Changes for handling unicode text. 80/62780/1
authorKyuho Jo <kyuho.jo@samsung.com>
Fri, 18 Mar 2016 07:15:32 +0000 (16:15 +0900)
committerKyuho Jo <kyuho.jo@samsung.com>
Fri, 18 Mar 2016 07:15:32 +0000 (16:15 +0900)
Change-Id: Ib031a77bfda736e65c8ceb88b370316786e19af9
Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
CMakeLists.txt
packaging/org.tizen.mediahub.spec
src/data/mediadata.c

index 7a8ab50..21f77cc 100644 (file)
@@ -26,6 +26,7 @@ pkg_check_modules(PKGS REQUIRED
                capi-ui-efl-util
                capi-maps-service
                vconf
+               capi-base-utils-i18n
                app-utils)
 
 IF(NOT DEFINED PACKAGE_NAME)
index d17f354..c2aed7c 100644 (file)
@@ -17,6 +17,7 @@ BuildRequires: pkgconfig(capi-ui-efl-util)
 BuildRequires: pkgconfig(capi-maps-service)
 BuildRequires: pkgconfig(vconf)
 BuildRequires: pkgconfig(app-utils)
+BuildRequires: pkgconfig(capi-base-utils-i18n)
 BuildRequires: pkgconfig(libtzplatform-config)
 
 %define _appdir %{TZ_SYS_RO_APP}/%{name}
index a31a3da..89618b7 100644 (file)
@@ -18,6 +18,7 @@
 #include <media_content.h>
 #include <app_debug.h>
 #include <app_media.h>
+#include <utils_i18n.h>
 
 #include "data/datamgr.h"
 
@@ -162,7 +163,54 @@ static char *_get_title(app_media_info *info)
        if (!info->title)
                return NULL;
 
-       return strndup(info->title, 1);
+       int buffer_length = 0;
+       i18n_error_code_e error_from_i18n;
+       char *result_str = NULL;
+       i18n_uchar *converted_str = NULL;
+       i18n_uchar sub_string[10] = { 0, };
+
+       /* Calc buffer size for converted UTF16 string */
+       i18n_ustring_from_UTF8(NULL, 0, &buffer_length, info->title, -1, &error_from_i18n);
+
+       converted_str = malloc((buffer_length + 2) * sizeof(i18n_uchar));
+       if (converted_str == NULL) {
+               _ERR("malloc failed");
+               goto OUT;
+       }
+
+       /* Convert to i18n(UTF16) string  */
+       i18n_ustring_from_UTF8(converted_str, buffer_length + 1, &buffer_length, info->title, -1, &error_from_i18n);
+       if (error_from_i18n != I18N_ERROR_NONE) {
+               _ERR("i18n_ustring_from_UTF8 returns [%d]", error_from_i18n);
+               goto OUT;
+       }
+       converted_str[buffer_length] = (i18n_uchar)0;
+
+       /* Get a character (not a byte) from left */
+       i18n_ustring_copy_n(sub_string, converted_str, 1);
+       i18n_ustring_to_UTF8(NULL, 0, &buffer_length, sub_string, -1, &error_from_i18n);
+
+       result_str = malloc((buffer_length + 2) * sizeof(char));
+       if (result_str == NULL) {
+               _ERR("malloc failed");
+               goto OUT;
+       }
+
+       /* Convert to UTF8 */
+       i18n_ustring_to_UTF8(result_str, buffer_length + 1, &buffer_length, sub_string, -1, &error_from_i18n);
+       if (error_from_i18n != I18N_ERROR_NONE) {
+               _ERR("i18n_ustring_to_UTF8 returns [%d]", error_from_i18n);
+               free(result_str);
+               result_str = NULL;
+               goto OUT;
+       }
+       result_str[buffer_length] = '\0';
+
+OUT:
+       if (converted_str)
+               free(converted_str);
+
+       return result_str;
 }
 
 static int _compare_time(struct group_info *gi, app_media_info *info)