[vlmc-devel] Fix import error when the path of a video contains Japanese characters.

Yikei Lu git at videolan.org
Tue Mar 1 19:25:08 CET 2016


vlmc | branch: master | Yikei Lu <luyikei.qmltu at gmail.com> | Tue Mar  1 23:31:40 2016 +0900| [686181bbb6ff4f8964231f9020ce3563343d753e] | committer: Hugo Beauzée-Luyssen

Fix import error when the path of a video contains Japanese characters.

Qt4 doesn't handle strings as UTF-8 in the default settings. According to VideoLan's documentation[1], it says "As a general rules, all character strings passed to LibVLC should be in UTF-8."
Therefore, by setting QTextCodec::setCodecForCStrings, Qt4 will use UTF-8 and the import error will be fixed.

References:
[1] https://wiki.videolan.org/Documentation:Unicode/

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> https://code.videolan.org/videolan/vlmc/commit/686181bbb6ff4f8964231f9020ce3563343d753e
---

 src/Main/main.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/Main/main.cpp b/src/Main/main.cpp
index eae00a2..a5598eb 100644
--- a/src/Main/main.cpp
+++ b/src/Main/main.cpp
@@ -47,6 +47,7 @@
 #include <QPalette>
 #include <QSettings>
 #include <QUuid>
+#include <QTextCodec>
 
 #ifdef Q_WS_X11
 #include <X11/Xlib.h>
@@ -83,6 +84,10 @@ VLMCGuimain( int argc, char **argv )
 #ifdef Q_WS_X11
     XInitThreads();
 #endif
+
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
+    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+#endif
     QApplication app( argc, argv );
 
     Backend::IBackend* backend;



More information about the Vlmc-devel mailing list