Closed kristofdegrave closed 3 years ago
When writing NULL values to a Dbase file, a string.empty is written instead: https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/3c952d5df92d1b5cc3c78b7f9d4815f129c2b719/src/NetTopologySuite.IO.ShapeFile/Dbase/DbaseFileWriter.cs#L151-L156 When we look at the write implemenation, we also see that the remaining bytes are filled with the value 0x20 (space) https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/3c952d5df92d1b5cc3c78b7f9d4815f129c2b719/src/NetTopologySuite.IO.ShapeFile/Dbase/DbaseFileWriter.cs#L320-L337
NULL
0x20
When reading the values of a dbase file, we don't take this into account. For example a NULL value for a boolean will be read as false. https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/3c952d5df92d1b5cc3c78b7f9d4815f129c2b719/src/NetTopologySuite.IO.ShapeFile/Dbase/DbaseFileReader.cs#L145-L150
false
So if the entire byte array length of the field is filled with spaces 0x20, can't we just convert this to null instead?
I think this is fixed now. Thanks!
When writing
NULL
values to a Dbase file, a string.empty is written instead: https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/3c952d5df92d1b5cc3c78b7f9d4815f129c2b719/src/NetTopologySuite.IO.ShapeFile/Dbase/DbaseFileWriter.cs#L151-L156 When we look at the write implemenation, we also see that the remaining bytes are filled with the value0x20
(space) https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/3c952d5df92d1b5cc3c78b7f9d4815f129c2b719/src/NetTopologySuite.IO.ShapeFile/Dbase/DbaseFileWriter.cs#L320-L337When reading the values of a dbase file, we don't take this into account. For example a
NULL
value for a boolean will be read asfalse
. https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/3c952d5df92d1b5cc3c78b7f9d4815f129c2b719/src/NetTopologySuite.IO.ShapeFile/Dbase/DbaseFileReader.cs#L145-L150So if the entire byte array length of the field is filled with spaces
0x20
, can't we just convert this to null instead?