NetTopologySuite / NetTopologySuite.IO.ShapeFile

The ShapeFile IO module for NTS.
35 stars 25 forks source link

set encoding bug #19

Closed bouyeijiang closed 4 months ago

bouyeijiang commented 5 years ago

set encoding error: this my code sample: ShapefileDataWriter.GetHeader(features[0], features.Count,Encoding.UTF8); error msg: Setting the encoding is only allowed once, either by means of the constructor or this property setter

and chinese random code error

akamsteeg commented 4 years ago

I worked around this issue by setting an encoding in the constructor too:

this._shapeFileWriter = new ShapefileDataWriter(streamRegistry, geometryFactory, Encoding.Default);

And I'm using the same encoding when writing the header:

this._shapeFileWriter.Header = ShapefileDataWriter.GetHeader(this._features[0], this._features.Count, Encoding.Default);
KubaSzostak commented 4 months ago

Support for a different encodings has been added in the successor library. There is also a sample code demonstrating how to custom encoding.