NetTopologySuite / NetTopologySuite.IO.Esri

BSD 3-Clause "New" or "Revised" License
35 stars 18 forks source link

Do not write BOM (byte order mark) in projection file #53

Closed FrankHileman closed 2 months ago

FrankHileman commented 3 months ago

In the recent changes adding stream support, we use a constructor for StreamWriter that results in using internally a UTF8Encoding that writes a BOM (byte order mark). At least one version of Arcgis cannot process such a file, and winds up having no projection. My colleague reported this; I don't have a license for Arcgis. I have figured out how to fix the problem, but not knowing if it is a thorough fix, I am attaching a patch file here, instead of using a pull request.

Note that if you use the UTF8Encoding constructor that takes a boolean, and pass it false, no BOM is written using such an encoding.

projection_bom_fix.patch

FrankHileman commented 3 months ago

Actually the field _utf8EncodingNoBOM is not needed; the static read only property would be sufficient.

KubaSzostak commented 2 months ago

Thank you @FrankHileman for your diligence and the detailed suggestions you provided. I’ve implemented the fix based on your recommendations, and it’s now in place. Please feel free to check if the new code works for you. If any issues arise, feel free to reopen this ticket.