Index: include/cdio/Makefile.am =================================================================== RCS file: /sources/libcdio/libcdio/include/cdio/Makefile.am,v retrieving revision 1.30 diff -u -r1.30 Makefile.am --- include/cdio/Makefile.am 27 Feb 2006 10:10:08 -0000 1.30 +++ include/cdio/Makefile.am 17 May 2006 19:36:03 -0000 @@ -50,6 +50,7 @@ udf.h \ udf_file.h \ udf_time.h \ + utf8.h \ util.h \ version.h \ xa.h Index: include/cdio/iso9660.h =================================================================== RCS file: /sources/libcdio/libcdio/include/cdio/iso9660.h,v retrieving revision 1.93 diff -u -r1.93 iso9660.h --- include/cdio/iso9660.h 6 May 2006 16:08:06 -0000 1.93 +++ include/cdio/iso9660.h 17 May 2006 19:36:06 -0000 @@ -916,7 +916,7 @@ is some problem in getting this and false is returned. */ bool iso9660_ifs_get_application_id(iso9660_t *p_iso, - /*out*/ char **p_psz_app_id); + /*out*/ cdio_utf8_t **p_psz_app_id); /*! Return the Joliet level recognized for p_iso. @@ -954,7 +954,7 @@ is some problem in getting this and false is returned. */ bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso, - /*out*/ char **p_psz_preparer_id); + /*out*/ cdio_utf8_t **p_psz_preparer_id); /*! Return a string containing the PVD's publisher id with trailing @@ -967,7 +967,7 @@ is some problem in getting this and false is returned. */ bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso, - /*out*/ char **p_psz_publisher_id); + /*out*/ cdio_utf8_t **p_psz_publisher_id); uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd); @@ -993,7 +993,7 @@ is some problem in getting this and false is returned. */ bool iso9660_ifs_get_system_id(iso9660_t *p_iso, - /*out*/ char **p_psz_system_id); + /*out*/ cdio_utf8_t **p_psz_system_id); /*! Return the LSN of the root directory for pvd. @@ -1012,7 +1012,7 @@ is some problem in getting this and false is returned. */ bool iso9660_ifs_get_volume_id(iso9660_t *p_iso, - /*out*/ char **p_psz_volume_id); + /*out*/ cdio_utf8_t **p_psz_volume_id); /*! Return the volumeset ID in the PVD. @@ -1025,7 +1025,7 @@ is some problem in getting this and false is returned. */ bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso, - /*out*/ char **p_psz_volumeset_id); + /*out*/ cdio_utf8_t **p_psz_volumeset_id); /* pathtable */ Index: include/cdio/types.h =================================================================== RCS file: /sources/libcdio/libcdio/include/cdio/types.h,v retrieving revision 1.35 diff -u -r1.35 types.h --- include/cdio/types.h 23 Jan 2006 20:47:33 -0000 1.35 +++ include/cdio/types.h 17 May 2006 19:36:07 -0000 @@ -202,7 +202,15 @@ typedef struct msf_s msf_t; #define msf_t_SIZEOF 3 - + + /*! + \brief UTF-8 char definition + + Type to denote UTF-8 strings. + */ + + typedef char cdio_utf8_t; + typedef enum { nope = 0, yep = 1, Index: lib/driver/Makefile.am =================================================================== RCS file: /sources/libcdio/libcdio/lib/driver/Makefile.am,v retrieving revision 1.15 diff -u -r1.15 Makefile.am --- lib/driver/Makefile.am 14 Mar 2006 12:05:16 -0000 1.15 +++ lib/driver/Makefile.am 17 May 2006 19:36:07 -0000 @@ -94,6 +94,7 @@ sector.c \ solaris.c \ track.c \ + utf8.c \ util.c lib_LTLIBRARIES = libcdio.la Index: lib/driver/libcdio.sym =================================================================== RCS file: /sources/libcdio/libcdio/lib/driver/libcdio.sym,v retrieving revision 1.35 diff -u -r1.35 libcdio.sym --- lib/driver/libcdio.sym 15 Apr 2006 03:05:14 -0000 1.35 +++ lib/driver/libcdio.sym 17 May 2006 19:36:07 -0000 @@ -205,3 +205,8 @@ mmc_start_stop_media mmc_timeout_ms track_format2str +cdio_charset_converter_create +cdio_charset_converter_destroy +cdio_charset_convert +cdio_charset_from_utf8 +cdio_charset_to_utf8 Index: lib/iso9660/iso9660_fs.c =================================================================== RCS file: /sources/libcdio/libcdio/lib/iso9660/iso9660_fs.c,v retrieving revision 1.35 diff -u -r1.35 iso9660_fs.c --- lib/iso9660/iso9660_fs.c 17 Mar 2006 22:36:31 -0000 1.35 +++ lib/iso9660/iso9660_fs.c 17 May 2006 19:36:10 -0000 @@ -33,10 +33,6 @@ # include #endif -#ifdef HAVE_ICONV -# include -#endif - #ifdef HAVE_LANGINFO_CODESET #include #endif @@ -45,6 +41,7 @@ #include #include #include +#include /* Private headers */ #include "cdio_assert.h" @@ -277,71 +274,13 @@ return true; } -#ifdef HAVE_JOLIET -static bool -ucs2be_to_locale(ICONV_CONST char *psz_ucs2be, size_t i_inlen, - char **p_psz_out, size_t i_outlen) -{ - - iconv_t ic = -#if defined(HAVE_LANGINFO_CODESET) - iconv_open(nl_langinfo(CODESET), "UCS-2BE"); -#else - iconv_open("ASCII", "UCS-2BE"); -#endif - - int rc; - char *psz_buf = NULL; - char *psz_buf2; - int i_outlen_max = i_outlen; - int i_outlen_actual; - - if (-1 == (size_t) ic) { -#if defined(HAVE_LANGINFO_CODESET) - cdio_info("Failed to get conversion table for locale, trying ASCII"); - ic = iconv_open("ASCII", "UCS-2BE"); - if (-1 == (size_t) ic) { - cdio_info("Failed to get conversion table for ASCII too"); - return false; - } -#else - cdio_info("Failed to get conversion table for locale"); - return false; -#endif - } - - psz_buf = (char *) realloc(psz_buf, i_outlen); - psz_buf2 = psz_buf; - if (!psz_buf) { - /* XXX: report out of memory error */ - goto error; - } - rc = iconv(ic, &psz_ucs2be, &i_inlen, &psz_buf2, &i_outlen); - iconv_close(ic); - if ((rc == -1) && (errno != E2BIG)) { - /* conversion failed */ - goto error; - } - i_outlen_actual = i_outlen_max - i_outlen; - *p_psz_out = malloc(i_outlen_actual + 1); - memcpy(*p_psz_out, psz_buf, i_outlen_actual); - *(*p_psz_out + i_outlen_actual) = '\0'; - free(psz_buf); - return true; - error: - free(psz_buf); - *p_psz_out = NULL; - return false; -} -#endif /*HAVE_JOLIET*/ - /*! Return the application ID. NULL is returned in psz_app_id if there is some problem in getting this. */ bool iso9660_ifs_get_application_id(iso9660_t *p_iso, - /*out*/ char **p_psz_app_id) + /*out*/ cdio_utf8_t **p_psz_app_id) { if (!p_iso) { *p_psz_app_id = NULL; @@ -355,10 +294,9 @@ longer results *and* have the same character using the PVD, do that. */ - if ( ucs2be_to_locale(p_iso->svd.application_id, - ISO_MAX_APPLICATION_ID, - p_psz_app_id, - ISO_MAX_APPLICATION_ID)) + if ( cdio_charset_to_utf8(p_iso->svd.application_id, + ISO_MAX_APPLICATION_ID, + p_psz_app_id, "UCS-2BE")) return true; } #endif /*HAVE_JOLIET*/ @@ -381,7 +319,7 @@ */ bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso, - /*out*/ char **p_psz_preparer_id) + /*out*/ cdio_utf8_t **p_psz_preparer_id) { if (!p_iso) { *p_psz_preparer_id = NULL; @@ -395,8 +333,8 @@ longer results *and* have the same character using the PVD, do that. */ - if ( ucs2be_to_locale(p_iso->svd.preparer_id, ISO_MAX_PREPARER_ID, - p_psz_preparer_id, ISO_MAX_PREPARER_ID) ) + if ( cdio_charset_to_utf8(p_iso->svd.preparer_id, ISO_MAX_PREPARER_ID, + p_psz_preparer_id, "UCS-2BE") ) return true; } #endif /*HAVE_JOLIET*/ @@ -409,7 +347,7 @@ blanks removed. */ bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso, - /*out*/ char **p_psz_publisher_id) + /*out*/ cdio_utf8_t **p_psz_publisher_id) { if (!p_iso) { *p_psz_publisher_id = NULL; @@ -423,8 +361,8 @@ longer results *and* have the same character using the PVD, do that. */ - if( ucs2be_to_locale(p_iso->svd.publisher_id, ISO_MAX_PUBLISHER_ID, - p_psz_publisher_id, ISO_MAX_PUBLISHER_ID) ) + if( cdio_charset_to_utf8(p_iso->svd.publisher_id, ISO_MAX_PUBLISHER_ID, + p_psz_publisher_id, "UCS-2BE") ) return true; } #endif /*HAVE_JOLIET*/ @@ -438,7 +376,7 @@ blanks removed. */ bool iso9660_ifs_get_system_id(iso9660_t *p_iso, - /*out*/ char **p_psz_system_id) + /*out*/ cdio_utf8_t **p_psz_system_id) { if (!p_iso) { *p_psz_system_id = NULL; @@ -452,8 +390,8 @@ longer results *and* have the same character using the PVD, do that. */ - if ( ucs2be_to_locale(p_iso->svd.system_id, ISO_MAX_SYSTEM_ID, - p_psz_system_id, ISO_MAX_SYSTEM_ID) ) + if ( cdio_charset_to_utf8(p_iso->svd.system_id, ISO_MAX_SYSTEM_ID, + p_psz_system_id, "UCS-2BE") ) return true; } #endif /*HAVE_JOLIET*/ @@ -467,7 +405,7 @@ blanks removed. */ bool iso9660_ifs_get_volume_id(iso9660_t *p_iso, - /*out*/ char **p_psz_volume_id) + /*out*/ cdio_utf8_t **p_psz_volume_id) { if (!p_iso) { *p_psz_volume_id = NULL; @@ -481,8 +419,8 @@ longer results *and* have the same character using the PVD, do that. */ - if ( ucs2be_to_locale(p_iso->svd.volume_id, ISO_MAX_VOLUME_ID, - p_psz_volume_id, ISO_MAX_VOLUME_ID) ) + if ( cdio_charset_to_utf8(p_iso->svd.volume_id, ISO_MAX_VOLUME_ID, + p_psz_volume_id, "UCS-2BE") ) return true; } #endif /* HAVE_JOLIET */ @@ -496,7 +434,7 @@ blanks removed. */ bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso, - /*out*/ char **p_psz_volumeset_id) + /*out*/ cdio_utf8_t **p_psz_volumeset_id) { if (!p_iso) { *p_psz_volumeset_id = NULL; @@ -510,10 +448,10 @@ longer results *and* have the same character using the PVD, do that. */ - if ( ucs2be_to_locale(p_iso->svd.volume_set_id, - ISO_MAX_VOLUMESET_ID, - p_psz_volumeset_id, - ISO_MAX_VOLUMESET_ID) ) + if ( cdio_charset_to_utf8(p_iso->svd.volume_set_id, + ISO_MAX_VOLUMESET_ID, + p_psz_volumeset_id, + "UCS-2BE") ) return true; } #endif /*HAVE_JOLIET*/ @@ -843,10 +781,10 @@ #ifdef HAVE_JOLIET else if (i_joliet_level) { int i_inlen = i_fname; - int i_outlen = (i_inlen / 2); - char *p_psz_out = NULL; - ucs2be_to_locale(p_iso9660_dir->filename, i_inlen, &p_psz_out, - i_outlen); + cdio_utf8_t *p_psz_out = NULL; + cdio_charset_to_utf8(p_iso9660_dir->filename, i_inlen, + &p_psz_out, "UCS-2BE"); + strncpy(p_stat->filename, p_psz_out, i_fname); free(p_psz_out); }