Fix AssetBundleStringExtractor for Swift 5
Apparently I was never supposed to use withMemoryRebound like that and it finally started checking that in Swift 5
This commit is contained in:
@@ -92,13 +92,12 @@ func stringFinder(data: Data, maxStringLength: Int = 100) -> [String] {
|
|||||||
let unicode = UnsafeBufferPointer(rebasing: ints[(index + 1)...].prefix(uint32Length))
|
let unicode = UnsafeBufferPointer(rebasing: ints[(index + 1)...].prefix(uint32Length))
|
||||||
// Ensure padding is all 0s
|
// Ensure padding is all 0s
|
||||||
guard padding == 0 || unicode.last!.littleEndian &>> (padding * 8) == 0 else { continue }
|
guard padding == 0 || unicode.last!.littleEndian &>> (padding * 8) == 0 else { continue }
|
||||||
let optionalStr = unicode.withMemoryRebound(to: UInt8.self) { (unicode) -> String? in
|
|
||||||
let stringUnicode = unicode[..<Int(int)]
|
let unicodeBytes = UnsafeRawBufferPointer(unicode).bindMemory(to: UInt8.self)
|
||||||
guard isValidUTF8(data: stringUnicode) else { return nil }
|
let stringUnicode = unicodeBytes[..<Int(int)]
|
||||||
return String(decoding: stringUnicode, as: UTF8.self)
|
guard isValidUTF8(data: stringUnicode) else { continue }
|
||||||
}
|
|
||||||
guard let str = optionalStr else { continue }
|
out.append(String(decoding: stringUnicode, as: UTF8.self))
|
||||||
out.append(str)
|
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user