diff --git a/libhb/dvd.c b/libhb/dvd.c index 4f6d8fa7a629..4c90fe119d32 100644 --- a/libhb/dvd.c +++ b/libhb/dvd.c @@ -113,21 +113,13 @@ hb_dvd_t * hb_dvdread_init( hb_handle_t * h, const char * path ) hb_dvd_t * e; hb_dvdread_t * d; int region_mask; - char * path_ccp; e = calloc( sizeof( hb_dvd_t ), 1 ); d = &(e->dvdread); d->h = h; - /* - * Convert UTF-8 path to current code page on Windows - * hb_utf8_to_cp() is the same as strdup on non-Windows, - * so no #ifdef required here - */ - path_ccp = hb_utf8_to_cp( path ); - /* Log DVD drive region code */ - if ( hb_dvd_region( path_ccp, ®ion_mask ) == 0 ) + if ( hb_dvd_region( path, ®ion_mask ) == 0 ) { hb_log( "dvd: Region mask 0x%02x", region_mask ); if ( region_mask == 0xFF ) @@ -137,7 +129,7 @@ hb_dvd_t * hb_dvdread_init( hb_handle_t * h, const char * path ) } /* Open device */ - if( !( d->reader = DVDOpen( path_ccp ) ) ) + if( !( d->reader = DVDOpen( path ) ) ) { /* * Not an error, may be a stream - which we'll try in a moment. @@ -153,8 +145,7 @@ hb_dvd_t * hb_dvdread_init( hb_handle_t * h, const char * path ) goto fail; } - d->path = strdup( path ); /* hb_dvdread_title_scan assumes UTF-8 path, so not path_ccp here */ - free( path_ccp ); + d->path = strdup( path ); return e; @@ -162,7 +153,6 @@ hb_dvd_t * hb_dvdread_init( hb_handle_t * h, const char * path ) if( d->vmg ) ifoClose( d->vmg ); if( d->reader ) DVDClose( d->reader ); free( e ); - free( path_ccp ); return NULL; } diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c index 32dbd1a96219..6a7b7d9a1760 100644 --- a/libhb/dvdnav.c +++ b/libhb/dvdnav.c @@ -103,12 +103,11 @@ static char * hb_dvdnav_name( char * path ) **********************************************************************/ static int hb_dvdnav_reset( hb_dvdnav_t * d ) { - char * path_ccp = hb_utf8_to_cp( d->path ); if ( d->dvdnav ) dvdnav_close( d->dvdnav ); /* Open device */ - if( dvdnav_open(&d->dvdnav, path_ccp) != DVDNAV_STATUS_OK ) + if( dvdnav_open(&d->dvdnav, d->path) != DVDNAV_STATUS_OK ) { /* * Not an error, may be a stream - which we'll try in a moment. @@ -137,13 +136,10 @@ static int hb_dvdnav_reset( hb_dvdnav_t * d ) goto fail; } - free( path_ccp ); - return 1; fail: if( d->dvdnav ) dvdnav_close( d->dvdnav ); - free( path_ccp ); return 0; } @@ -157,21 +153,13 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path ) hb_dvd_t * e; hb_dvdnav_t * d; int region_mask; - char * path_ccp; e = calloc( sizeof( hb_dvd_t ), 1 ); d = &(e->dvdnav); d->h = h; - /* - * Convert UTF-8 path to current code page on Windows - * hb_utf8_to_cp() is the same as strdup on non-Windows, - * so no #ifdef required here - */ - path_ccp = hb_utf8_to_cp( path ); - /* Log DVD drive region code */ - if ( hb_dvd_region( path_ccp, ®ion_mask ) == 0 ) + if ( hb_dvd_region( path, ®ion_mask ) == 0 ) { hb_log( "dvd: Region mask 0x%02x", region_mask ); if ( region_mask == 0xFF ) @@ -181,7 +169,7 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path ) } /* Open device */ - if( dvdnav_open(&d->dvdnav, path_ccp) != DVDNAV_STATUS_OK ) + if( dvdnav_open(&d->dvdnav, path) != DVDNAV_STATUS_OK ) { /* * Not an error, may be a stream - which we'll try in a moment. @@ -211,7 +199,7 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path ) } /* Open device */ - if( !( d->reader = DVDOpen( path_ccp ) ) ) + if( !( d->reader = DVDOpen( path ) ) ) { /* * Not an error, may be a stream - which we'll try in a moment. @@ -227,8 +215,7 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path ) goto fail; } - d->path = strdup( path ); /* hb_dvdnav_title_scan assumes UTF-8 path, so not path_ccp here */ - free( path_ccp ); + d->path = strdup( path ); return e; @@ -237,7 +224,6 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path ) if( d->vmg ) ifoClose( d->vmg ); if( d->reader ) DVDClose( d->reader ); free( e ); - free( path_ccp ); return NULL; } diff --git a/libhb/handbrake/ports.h b/libhb/handbrake/ports.h index 2a2acb4e6060..4cb26229c95f 100644 --- a/libhb/handbrake/ports.h +++ b/libhb/handbrake/ports.h @@ -134,15 +134,12 @@ size_t hb_getline(char **lineptr, size_t *n, FILE *fp); #ifdef __LIBHB__ -// Convert utf8 string to current code page. -char * hb_utf8_to_cp(const char *src); - /* Everything from now is only used internally and hidden to the UI */ /************************************************************************ * DVD utils ***********************************************************************/ -int hb_dvd_region(char *device, int *region_mask); +int hb_dvd_region(const char *device, int *region_mask); #if defined( SYS_DARWIN ) int macOS_get_user_config_directory( char path[512] ); diff --git a/libhb/ports.c b/libhb/ports.c index bdd9adcf920d..10c9742cf626 100644 --- a/libhb/ports.c +++ b/libhb/ports.c @@ -109,35 +109,7 @@ int gettimeofday( struct timeval * tv, struct timezone * tz ) #endif */ -// Convert utf8 string to current code page. -// The internal string representation in hb is utf8. But some -// libraries (libmkv, and mp4v2) expect filenames in the current -// code page. So we must convert. -char * hb_utf8_to_cp(const char *src) -{ - char *dst = NULL; - -#if defined( SYS_MINGW ) - int num_chars = MultiByteToWideChar(CP_UTF8, 0, src, -1, NULL, 0); - if (num_chars <= 0) - return NULL; - wchar_t * tmp = calloc(num_chars, sizeof(wchar_t)); - MultiByteToWideChar(CP_UTF8, 0, src, -1, tmp, num_chars); - int len = WideCharToMultiByte(GetACP(), 0, tmp, num_chars, NULL, 0, NULL, NULL); - if (len <= 0) - return NULL; - dst = calloc(len, sizeof(char)); - WideCharToMultiByte(GetACP(), 0, tmp, num_chars, dst, len, NULL, NULL); - free(tmp); -#else - // Other platforms don't have code pages - dst = strdup(src); -#endif - - return dst; -} - -int hb_dvd_region(char *device, int *region_mask) +int hb_dvd_region(const char *device, int *region_mask) { #if defined( DVD_LU_SEND_RPC_STATE ) && defined( DVD_AUTH ) struct stat st;