Replace invalid utf-8 characters with underscores. Bump cache version.
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
const int FILE_CACHE_VERSION = 145; // increment this to invalidate cache
|
const int FILE_CACHE_VERSION = 146; // increment this to invalidate cache
|
||||||
|
|
||||||
const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f;
|
const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f;
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,16 @@ RString SongCacheIndex::GetCacheFilePath( const RString &sGroup, const RString &
|
|||||||
/* Don't use GetHashForFile, since we don't want to spend time
|
/* Don't use GetHashForFile, since we don't want to spend time
|
||||||
* checking the file size and date. */
|
* checking the file size and date. */
|
||||||
RString s = sPath;
|
RString s = sPath;
|
||||||
s.Replace( '/', '_' );
|
/* Change slashes and invalid utf-8 characters to _.
|
||||||
return ssprintf( "%s/%s/%s", SpecialFiles::CACHE_DIR.c_str(), sGroup.c_str(), s.c_str() );
|
* http://en.wikipedia.org/wiki/UTF-8
|
||||||
|
* Mac OS X doesn't support precomposed unicode characters in files names and
|
||||||
|
* so we should probably replace them with combining diacritics.
|
||||||
|
* XXX How do we do this and is it even worth it? */
|
||||||
|
const char *invalid = "/\xc0\xc1\xfe\xff\xf8\xf9\xfa\xfb\xfc\xfd\xf5\xf6\xf7";
|
||||||
|
for( size_t pos = s.find_first_of(invalid); pos != RString::npos; pos = s.find_first_of(invalid, pos) )
|
||||||
|
s[pos] = '_';
|
||||||
|
// CACHE_DIR ends with a /.
|
||||||
|
return ssprintf( "%s%s/%s", SpecialFiles::CACHE_DIR.c_str(), sGroup.c_str(), s.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
SongCacheIndex::SongCacheIndex()
|
SongCacheIndex::SongCacheIndex()
|
||||||
|
|||||||
Reference in New Issue
Block a user