]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/wxwidgets.hpp
* skins2: when restoring the previous skin because a new one failed to load,
[vlc] / modules / gui / wxwidgets / wxwidgets.hpp
index bd69b13acebb87dcdc478268b58956bae99bb226..2b723023d06acbe5359a1886c72a7568088e153d 100644 (file)
@@ -69,33 +69,45 @@ DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 );
  * I18N macros
  ***************************************************************************/
 
-/* wxU is used to convert ansi/utf8 strings to unicode strings (wchar_t) */
-#if defined( ENABLE_NLS )
+/*
+ * wxU() is used to convert UTF-8 strings (typically from gettext)
+ * to unicode strings (wchar_t).
+ */
 #if wxUSE_UNICODE
 #   define wxU(utf8) wxString(utf8, wxConvUTF8)
 #else
 #   define wxU(utf8) wxString(wxConvUTF8.cMB2WC(utf8), *wxConvCurrent)
 #endif
-#else // ENABLE_NLS
-#if wxUSE_UNICODE
-#   define wxU(ansi) wxString(ansi, wxConvLocal)
-#else
-#   define wxU(ansi) (ansi)
-#endif
-#endif
 
-/* wxL2U (locale to unicode) is used to convert ansi strings to unicode
- * strings (wchar_t) */
-#define wxL2U(ansi) wxU(ansi)
+/*
+ * wxL2U() use to convert localized “data” strings (while wxU() would convert
+ * strings from gettext messages). Nowadays, the core use UTF-8 internally
+ * and wxL2U() is only an obsoleted name for wxU().
+ */
+#define wxL2U(utf8) wxU(utf8)
 
+/*
+ * wxFromLocale() is a replacement for LibVLC FromLocale() that accepts
+ * a wxString. It was originally introduced because wxString::mb_str()
+ * sucks on Linux with Unicode wxWidgets. It then turned out wxWidgets
+ * did not support wc_str() when Unicode was not enabled.
+ *
+ * But heh, that's wxWidgets; you can't really expect it to actually
+ * work, let alone work like its documentation says.
+ *
+ * Did it work, we would be able to catch non-ANSI characters on Windows
+ * through wxString::wc_str(); while they are lost when using mb_str().
+ * This would be particularly useful to open files whose names contain
+ * non-ACP characters.
+ */
 #if wxUSE_UNICODE
-#   define wxFromLocale(wxstring) FromUTF32(wxstring.wc_str())
+#   define wxFromLocale(wxstring) FromWide(wxstring.wc_str())
 #   define wxLocaleFree(string) free(string)
 #else
 #   define wxFromLocale(wxstring) FromLocale(wxstring.mb_str())
 #   define wxLocaleFree(string) LocaleFree(string)
 #endif
-
+       
 /* From Locale functions to use for File Drop targets ... go figure */
 #ifdef wxUSE_UNICODE
 static inline char *wxDnDFromLocale( const wxChar *stupid )
@@ -120,14 +132,12 @@ static inline char *wxDnDFromLocale( const wxChar *stupid )
     for (braindead = stupid; *braindead; braindead++);
 
     size_t i = (braindead - stupid);
-    char *psz_local = (char *)malloc( i + 1 );
+    char psz_local[i + 1];
     do
         psz_local[i] = (char)stupid[i];
     while (i--);
 
-    char *psz_utf8 = FromLocaleDup( psz_local );
-    free( psz_local );
-    return psz_utf8;
+    return FromLocaleDup( psz_local );
 }
 #   define wxDnDLocaleFree( string ) free( string )
 #else