Replace invalid utf-8 characters with underscores. Bump cache version.
This commit is contained in:
@@ -34,8 +34,16 @@ RString SongCacheIndex::GetCacheFilePath( const RString &sGroup, const RString &
|
||||
/* Don't use GetHashForFile, since we don't want to spend time
|
||||
* checking the file size and date. */
|
||||
RString s = sPath;
|
||||
s.Replace( '/', '_' );
|
||||
return ssprintf( "%s/%s/%s", SpecialFiles::CACHE_DIR.c_str(), sGroup.c_str(), s.c_str() );
|
||||
/* Change slashes and invalid utf-8 characters to _.
|
||||
* 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()
|
||||
|
||||
Reference in New Issue
Block a user