]> git.sesse.net Git - vlc/commitdiff
* skins2: fixed several encoding issues. In particular, it should now be
authorOlivier Teulière <ipkiss@videolan.org>
Sun, 23 Jul 2006 22:19:46 +0000 (22:19 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Sun, 23 Jul 2006 22:19:46 +0000 (22:19 +0000)
   possible to load a skin on Windows when logged with an account containing
   non-english characters.

modules/gui/skins2/parser/builder.cpp
modules/gui/skins2/src/skin_common.hpp
modules/gui/skins2/src/theme_loader.cpp
modules/gui/skins2/src/theme_loader.hpp

index dc970d444e8563d253af8f88de8516e7e9d4709a..9eba9dc3631a66102dd926ea5bf4f76088599163 100644 (file)
@@ -1061,7 +1061,7 @@ GenericFont *Builder::getFont( const string &fontId )
 string Builder::getFilePath( const string &rFileName ) const
 {
     OSFactory *pFactory = OSFactory::instance( getIntf() );
-    return m_path + pFactory->getDirSeparator() + rFileName;
+    return m_path + pFactory->getDirSeparator() + sFromLocale( rFileName );
 }
 
 
index d87473a8cccd61e0fad2bbf0d49e303163f006f5..c8037aabe25db483ffa082f845ea155d104a45af 100644 (file)
@@ -66,6 +66,26 @@ class ThemeRepository;
    }
 
 
+/// Wrapper around FromLocale, to avoid the need to call LocaleFree()
+static inline string sFromLocale( const string &rLocale )
+{
+    char *s = FromLocale( rLocale.c_str() );
+    string res = s;
+    LocaleFree( s );
+    return res;
+}
+
+
+/// Wrapper around ToLocale, to avoid the need to call LocaleFree()
+static inline string sToLocale( const string &rUTF8 )
+{
+    char *s = ToLocale( rUTF8.c_str() );
+    string res = s;
+    LocaleFree( s );
+    return res;
+}
+
+
 //---------------------------------------------------------------------------
 // intf_sys_t: description and status of skin interface
 //---------------------------------------------------------------------------
index 51e36f809adc7fbdb76b72afb1eaa9cf4dc54c84..73655004e66b51c3667be8ec4d8249091081c527 100644 (file)
@@ -77,7 +77,7 @@ bool ThemeLoader::load( const string &fileName )
     // file...
     string path = getFilePath( fileName );
 #if defined( HAVE_ZLIB_H )
-    if( ! extract( fileName ) && ! parse( path, fileName ) )
+    if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) )
         return false;
 #else
     if( ! parse( path, fileName ) )
@@ -311,7 +311,7 @@ bool ThemeLoader::extract( const string &fileName )
             list<string>::const_iterator it;
             for( it = resPath.begin(); it != resPath.end(); it++ )
             {
-                if( findFile( *it, WINAMP2_XML_FILE, xmlFile ) )
+                if( findFile( sToLocale( *it ), WINAMP2_XML_FILE, xmlFile ) )
                     break;
             }
         }
@@ -456,7 +456,7 @@ bool ThemeLoader::findFile( const string &rootDir, const string &rFileName,
                 // Found the theme file?
                 if( rFileName == string( pDirContent->d_name ) )
                 {
-                    themeFilePath = newURI;
+                    themeFilePath = sFromLocale( newURI );
                     closedir( pCurrDir );
                     return true;
                 }
index 8a672cbaf9d754a14999696f93104069e3c1471a..ea001984c1ecfbde8f364c70196d33b35216b05f 100644 (file)
@@ -37,33 +37,59 @@ class ThemeLoader: public SkinObject
         ThemeLoader( intf_thread_t *pIntf ): SkinObject( pIntf ) {}
         virtual ~ThemeLoader() {}
 
+        /**
+         * The expected fileName must be an UTF-8 string (usually the result of
+         * a call to FromLocale())
+         */
         bool load( const string &fileName );
 
     private:
 #if defined( HAVE_ZLIB_H )
         /// Extract files from an archive (handles tar.gz and zip)
+        /**
+         * Expects a string from the current locale.
+         */
         bool extract( const string &fileName );
 
         /// Extract files from a tar.gz archive
+        /**
+         * Expects strings from the current locale.
+         */
         bool extractTarGz( const string &tarFile, const string &rootDir );
 
         /// Extract files from a .zip archive
+        /**
+         * Expects strings from the current locale.
+         */
         bool extractZip( const string &zipFile, const string &rootDir );
 
         /// Extract the current file from a .zip archive
+        /**
+         * Expects a string from the current locale.
+         */
         bool extractFileInZip( unzFile file, const string &rootDir );
 
         /// Clean up the temporary files created by the extraction
+        /**
+         * Expects a string from the current locale.
+         */
         void deleteTempFiles( const string &path );
 #endif
 
         /// Parse the XML file given as a parameter and build the skin
+        /**
+         * Expects UTF8 strings
+         */
         bool parse( const string &path, const string &xmlFile );
 
         /// Recursively look for the XML file from rootDir.
-        /// The first corresponding file found will be chosen and themeFilePath
-        /// will be updated accordingly.
-        /// The method returns true if a theme file was found, false otherwise
+        /**
+         * The first corresponding file found will be chosen and themeFilePath
+         * will be updated accordingly.
+         * The method returns true if a theme file was found, false otherwise.
+         * rootDir and rFilename must both be strings in the current locale,
+         * whereas themeFilePath will be in UTF8.
+         */
         bool findFile( const string &rootDir, const string &rFileName,
                        string &themeFilePath );