I just assumed that everything was going to be utf8. Happy to review a pull request with a test.
Ian On Tue, 10 May 2022, 13:41 Tobias Gerdin, <tobias.ger...@havochvatten.se> wrote: > Hello, > > > > I was puzzled by the behaviour of org.geotools.data.geojson.GeoJSONReader > when I was using it to read a feature collection containing non-ascii > strings. It complains that the JSON string contains invalid UTF-8 data. > > > > Due to client mandate I need to develop on a Windows 11 machine. The > default platform encoding is windows-1252 (for archeological reasons, I > guess), not UTF8. I noticed that GeoJSONReader uses plain String.getBytes() > to read the JSON data ( > https://github.com/geotools/geotools/blob/f416fcc3763b2db020c54a9323601fbdd49388e7/modules/unsupported/geojson-core/src/main/java/org/geotools/data/geojson/GeoJSONReader.java#L179 > ). > > > > When I change the JVM charset encoding (which needs to be done at startup) > using -Dfile.encoding=”UTF-8” my code works, but I rather not have to do > this. I am not an expert on JSON but I recall the spec mandates that JSON > data is encoded in UTF-8. So I believe that the above linked line should do > jsonString.getBytes(StandardCharsets.*UTF_8*) (and in all other locations > where JSON data is read). > > > > Apparently Java is slated to go UTF-8 by default in the future, but until > then we need to deal with this mess I guess. > > > [image: Havochvatten] > > *Tobias Gerdin* > > Systemutvecklare, Konsult > > Enheten för systemutveckling > > > > Gullbergs Strandgata 15, 411 04 Göteborg > > Box 11930, SE-404 39 Göteborg > > tobias.ger...@havochvatten.se > > www.havochvatten.se > [image: Havochvatten] > Havs- och vattenmyndigheten behandlar dina personuppgifter i enlighet med > dataskyddsförordningen och myndighetens dataskyddspolicy, läs mer på > www.havochvatten.se/sa-behandlar-hav-dina-personuppgifter > SwAM processes your personal data in accordance with the General Data > Protection Regulation (GDPR) and our Data Protection Policy, see > www.havochvatten.se/sa-behandlar-hav-dina-personuppgifter > _______________________________________________ > GeoTools-Devel mailing list > GeoTools-Devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-devel >
_______________________________________________ GeoTools-Devel mailing list GeoTools-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel