From f0c86de5931d6e9b24605b83674f0c9fa71d1339 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 9 Jun 2024 01:30:11 +0200 Subject: [PATCH] Remove wchar/unicode handling --- mediainfo.go | 4 ---- mediainfo.h | 31 +++++-------------------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/mediainfo.go b/mediainfo.go index 916a884..e6df6d5 100644 --- a/mediainfo.go +++ b/mediainfo.go @@ -1,7 +1,6 @@ package mediainfo // #include -// #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() } diff --git a/mediainfo.h b/mediainfo.h index f2560f9..084b90a 100644 --- a/mediainfo.h +++ b/mediainfo.h @@ -1,27 +1,6 @@ -#include #include -#include -#include #include -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); }