Improvement: Hopefully improve tag loading speed
Hopefully this works for most ASCII and UTF-8 tags, and continues to work for weird tag encodings. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
b4b0deebd2
commit
b631cf803e
1 changed files with 8 additions and 2 deletions
|
@ -108,7 +108,13 @@
|
|||
|
||||
static NSString *guess_encoding_of_string(const char *input) {
|
||||
NSString *ret = @"";
|
||||
NSData *stringData = [NSData dataWithBytes:input length:strlen(input)];
|
||||
[NSString stringEncodingForData:stringData encodingOptions:nil convertedString:&ret usedLossyConversion:nil];
|
||||
@try {
|
||||
ret = [NSString stringWithUTF8String:input];
|
||||
}
|
||||
@catch(id anException) {
|
||||
// This method is incredibly slow
|
||||
NSData *stringData = [NSData dataWithBytes:input length:strlen(input)];
|
||||
[NSString stringEncodingForData:stringData encodingOptions:nil convertedString:&ret usedLossyConversion:nil];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue