Use String.init(decoding:as:) initializer instead of .init(bytes:encoding:) in SyncParser.parse(_:String) method

This commit is contained in:
Caleb Kleveter 2019-04-18 09:47:08 -05:00
parent fa20a47458
commit 502da1cb59
No known key found for this signature in database
GPG Key ID: B38DBD5CF2C98D69
1 changed files with 4 additions and 6 deletions

View File

@ -164,14 +164,12 @@ extension CSV {
var results: [String: [String?]] = [:]
var parser = Parser(
onHeader: { header in
if let title = String(bytes: header, encoding: .utf8) {
results[title] = []
}
results[String(decoding: header, as: UTF8.self)] = []
},
onCell: { header, cell in
if let title = String(bytes: header, encoding: .utf8), let contents = String(bytes: cell, encoding: .utf8) {
results[title, default: []].append(cell.count > 0 ? contents : nil)
}
let title = String(decoding: header, as: UTF8.self)
let contents = String(decoding: cell, as: UTF8.self)
results[title, default: []].append(cell.count > 0 ? contents : nil)
}
)