From 90c63676529c30063994aa4e2650754f8ca4856c Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 15 Nov 2010 16:00:23 -0800 Subject: Make CFCString() accept non-UTF8 data without horrible error. --- MobileCydia.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'MobileCydia.mm') diff --git a/MobileCydia.mm b/MobileCydia.mm index 8b0ae70..03d76f5 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -1070,7 +1070,11 @@ NSString *SizeString(double size) { } static _finline CFStringRef CFCString(const char *value) { - return CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast(value), strlen(value), kCFStringEncodingUTF8, NO, kCFAllocatorNull); + size_t size(strlen(data)); + + return + CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast(data), size, kCFStringEncodingUTF8, NO, kCFAllocatorNull) ?: + CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast(data), size, kCFStringEncodingISOLatin1, NO, kCFAllocatorNull); } const char *StripVersion_(const char *version) { -- cgit v1.2.3