diff --git a/Sources/XCLogParser/loglocation/LogLoader.swift b/Sources/XCLogParser/loglocation/LogLoader.swift index 4a39b88..c7bfcd3 100644 --- a/Sources/XCLogParser/loglocation/LogLoader.swift +++ b/Sources/XCLogParser/loglocation/LogLoader.swift @@ -26,7 +26,18 @@ public struct LogLoader { do { let data = try Data(contentsOf: url) let unzipped = try data.gunzipped() - guard let contents = String(data: unzipped, encoding: .ascii) else { + let string: String? = unzipped.withUnsafeBytes { pointer in + guard let charPointer = pointer + .assumingMemoryBound(to: CChar.self) + .baseAddress + else { + return nil + } + + return String(cString: charPointer, encoding: .ascii) + } + + guard let contents = string else { throw LogError.readingFile(url.path) } return contents