Open TomQv opened 4 years ago
Hi TomQv, i have a similar problem, but when i write a shapefile. Do you found any solution for your problem? I also use NetTopologySuite.Features 2.0 NetTopologySuite.IO.Shapefile 2.0 on xamarin.
Thanks in advance
Hi, no, unfortunate not yet. I mean, I downloaded the source, commented out DetectEncoding() because I don't have text in that specific project so its working with me. But of course this is just a workaround if you don't have text in db.
Perfect, i haven text also, so, do you download the project from here https://github.com/NetTopologySuite/NetTopologySuite???
because i go to do the same.
A lot of thanks for your pretty fast response TomQv.
I only downloaded https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile Because I only need Shp. You must add a reference to NetTopologySuite.Features.
These are my changes only in file DbaseEncodingUtility:
internal static readonly Encoding Latin1 = Encoding.UTF8; // TOM GetEncodingForCodePageName("iso-8859-1");
public static Encoding DefaultEncoding { get; set; } = Encoding.UTF8; // TOM GetEncodingForCodePageIdentifier(1252);
public static Encoding GetEncodingForCodePageIdentifier(int codePage) => DefaultEncoding; // TOM CodePagesEncodingProvider.Instance.GetEncoding(codePage);
public static Encoding GetEncodingForCodePageName(string name) => DefaultEncoding; // TOM CodePagesEncodingProvider.Instance.GetEncoding(name) ?? Encoding.GetEncoding(name);
Thanks a lot Tom,
i done the same, but my bug was another, in the method GetLdidFromEncoding; i added a try catch and is done:
private static byte GetLdidFromEncoding(Encoding encoding)
{
byte ldid;
try
{
if (!DbaseEncodingUtility.EncodingToLdid.TryGetValue(encoding, out ldid))
ldid = 0x03;
}
catch
{
ldid = 0x03;
}
return ldid;
}
Thanks.
👍
Hi @TomQv, do you need more support on this issue? If so, provide further details, please.
Im trying to read shp-files in a Xamarin.Mac project with NetTopologySuite.IO.Shapefile 2.0.0. Project is targeting Xamarin.Mac Full NET 4.8.
Calling _
reader = new ShapefileDataReader(file, _geometryFactory, System.Text.Encoding.Default);
results in ArgumentNullException, see stacktrace below.With a plain .NET Core 3.0 project, everything is fine.
Any ideas?