Remove wchar/unicode handling

This commit is contained in:
2024-06-09 01:30:11 +02:00
parent 07018f07ef
commit f0c86de593
2 changed files with 5 additions and 30 deletions

View File

@@ -1,7 +1,6 @@
package mediainfo
// #include <mediainfo.h>
// #cgo CFLAGS: -DUNICODE
// #cgo LDFLAGS: -ldl -lmediainfo
import "C"
import (
@@ -46,9 +45,6 @@ const (
)
func init() {
str := C.CString("")
defer C.free(unsafe.Pointer(str))
C.setlocale(C.LC_CTYPE, str)
C.MediaInfoDLL_Load()
}

View File

@@ -1,27 +1,6 @@
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <MediaInfoDLL/MediaInfoDLL.h>
const wchar_t *toWchar(const char *c)
{
const size_t cSize = strlen(c) + 1;
wchar_t *wc = malloc(cSize * sizeof(wchar_t));
mbstowcs(wc, c, cSize);
return wc;
}
const char *toChar(const wchar_t *c)
{
const size_t cSize = wcslen(c) + 1;
char *wc = malloc(cSize * sizeof(char));
wcstombs(wc, c, cSize);
return wc;
}
void *OpenFile(char *filePath)
{
void *handle = MediaInfo_New();
@@ -30,7 +9,7 @@ void *OpenFile(char *filePath)
return NULL;
}
size_t res = MediaInfo_Open(handle, toWchar(filePath));
size_t res = MediaInfo_Open(handle, filePath);
if (!res)
{
return NULL;
@@ -47,20 +26,20 @@ void CloseFile(void *handle)
const char *Get(void *handle, MediaInfo_stream_C streamKind, size_t StreamNumber, char *Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch)
{
return toChar(MediaInfo_Get(handle, streamKind, StreamNumber, toWchar(Parameter), KindOfInfo, KindOfSearch));
return MediaInfo_Get(handle, streamKind, StreamNumber, Parameter, KindOfInfo, KindOfSearch);
}
const char *GetI(void *handle, MediaInfo_stream_C streamKind, size_t StreamNumber, unsigned long Parameter, MediaInfo_info_C KindOfInfo)
{
return toChar(MediaInfo_GetI(handle, streamKind, StreamNumber, Parameter, KindOfInfo));
return MediaInfo_GetI(handle, streamKind, StreamNumber, Parameter, KindOfInfo);
}
const char *Option(void *handle, char *Parameter, char *Value)
{
return toChar(MediaInfo_Option(handle, toWchar(Parameter), toWchar(Value)));
return MediaInfo_Option(handle, Parameter, Value);
}
const char *Inform(void *handle, size_t Reserved)
{
return toChar(MediaInfo_Inform(handle, Reserved));
return MediaInfo_Inform(handle, Reserved);
}