Skip to content

Commit

Permalink
go directly from bytes until 0 to Symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Oct 13, 2023
1 parent c477b43 commit b09073f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/DBFTables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ end

"Read a field descriptor from the stream, and create a FieldDescriptor struct"
function read_dbf_field(io::IO)
field_name_raw = String(read!(io, Vector{UInt8}(undef, 11)))
field_name = Symbol(split(field_name_raw, '\0')[1])
field_name_bytes = read(io, 11)
i = findfirst(iszero, field_name_bytes)
n = i === nothing ? 11 : i - 1
field_name = Symbol(field_name_bytes[1:n])
field_type = read(io, Char)
skip(io, 4) # skip
field_len = read(io, UInt8)
Expand Down

0 comments on commit b09073f

Please sign in to comment.