From 2eb8e84d599cc1dd0367e5a931b39029af511d97 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 24 Jun 2013 09:23:14 +0000 Subject: [PATCH] * try fix the OSX / libmediainfo issues with accented characters. Using NFD is start but doesn't seem to work. @see http://www.filebot.net/forums/viewtopic.php?f=8&t=766 --- .../net/sourceforge/filebot/mediainfo/MediaInfo.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/net/sourceforge/filebot/mediainfo/MediaInfo.java b/source/net/sourceforge/filebot/mediainfo/MediaInfo.java index c3eb6113..e601651c 100644 --- a/source/net/sourceforge/filebot/mediainfo/MediaInfo.java +++ b/source/net/sourceforge/filebot/mediainfo/MediaInfo.java @@ -5,6 +5,8 @@ package net.sourceforge.filebot.mediainfo; import java.io.Closeable; import java.io.File; import java.io.IOException; +import java.text.Normalizer; +import java.text.Normalizer.Form; import java.util.ArrayList; import java.util.EnumMap; import java.util.LinkedHashMap; @@ -46,7 +48,15 @@ public class MediaInfo implements Closeable { public synchronized boolean open(File file) { - return file.isFile() && MediaInfoLibrary.INSTANCE.Open(handle, new WString(file.getAbsolutePath())) > 0; + if (!file.isFile()) + return false; + + // MacOS filesystem may require NFD unicode decomposition (forcing NFD seems to work for System.out() but passing to libmediainfo is still not working) + String path = file.getAbsolutePath(); + if (Platform.isMac()) { + path = Normalizer.normalize(path, Form.NFD); + } + return MediaInfoLibrary.INSTANCE.Open(handle, new WString(path)) > 0; }