From b09073fdf35c01c44fc1e1faa017481ea9692492 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 13 Oct 2023 22:30:56 +0200 Subject: [PATCH] go directly from bytes until 0 to Symbol --- src/DBFTables.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/DBFTables.jl b/src/DBFTables.jl index 53eda3c..8099084 100644 --- a/src/DBFTables.jl +++ b/src/DBFTables.jl @@ -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)