Skip to content

Commit a864a76

Browse files
committed
Update BinaryReader.swift
1 parent 2b4aa0c commit a864a76

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/BinaryReader/BinaryReader.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,12 @@ public class BinaryReader: Readable {
162162
return try readUInt8() != 0
163163
}
164164

165+
public func readString(length : UInt) throws -> String {
166+
let bytes = try readBytes(count: UInt(length))
167+
return String(bytes: bytes, encoding: .utf8) ?? ""
168+
}
169+
165170
public func readString() throws -> String {
166-
167171
var header = try readUInt8()
168172
var length = header & 0x7F
169173

0 commit comments

Comments
 (0)