Skip to content

Commit e99f7f2

Browse files
Merge pull request #2 from etsy/ugonzalez/adding-ascii-fix-to-fork
Updating ascii parsing
2 parents 251e44b + ef1f0e5 commit e99f7f2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sources/XCLogParser/loglocation/LogLoader.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@ public struct LogLoader {
2626
do {
2727
let data = try Data(contentsOf: url)
2828
let unzipped = try data.gunzipped()
29-
guard let contents = String(data: unzipped, encoding: .ascii) else {
29+
let string: String? = unzipped.withUnsafeBytes { pointer in
30+
guard let charPointer = pointer
31+
.assumingMemoryBound(to: CChar.self)
32+
.baseAddress
33+
else {
34+
return nil
35+
}
36+
37+
return String(cString: charPointer, encoding: .ascii)
38+
}
39+
40+
guard let contents = string else {
3041
throw LogError.readingFile(url.path)
3142
}
3243
return contents

0 commit comments

Comments
 (0)