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))
|
||||
// Ensure padding is all 0s
|
||||
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)]
|
||||
guard isValidUTF8(data: stringUnicode) else { return nil }
|
||||
return String(decoding: stringUnicode, as: UTF8.self)
|
||||
}
|
||||
guard let str = optionalStr else { continue }
|
||||
out.append(str)
|
||||
|
||||
let unicodeBytes = UnsafeRawBufferPointer(unicode).bindMemory(to: UInt8.self)
|
||||
let stringUnicode = unicodeBytes[..<Int(int)]
|
||||
guard isValidUTF8(data: stringUnicode) else { continue }
|
||||
|
||||
out.append(String(decoding: stringUnicode, as: UTF8.self))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user