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
2f9d7fe66d
commit
c7a160a9e7
1 changed files with 8 additions and 2 deletions
|
@ -108,7 +108,13 @@
|
||||||
|
|
||||||
static NSString *guess_encoding_of_string(const char *input) {
|
static NSString *guess_encoding_of_string(const char *input) {
|
||||||
NSString *ret = @"";
|
NSString *ret = @"";
|
||||||
NSData *stringData = [NSData dataWithBytes:input length:strlen(input)];
|
@try {
|
||||||
[NSString stringEncodingForData:stringData encodingOptions:nil convertedString:&ret usedLossyConversion:nil];
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue