graphhopper / geocoder-converter

Converts arbitrary geocoding responses to a GraphHopper response
https://graphhopper.com/api/1/docs/geocoding/#external-providers
Apache License 2.0
9 stars 11 forks source link

Encoding issue with special characters #14

Closed boldtrn closed 8 years ago

boldtrn commented 8 years ago

It seems that we have an issue with the encoding.

Characters like: ä,ü,ö,ß are returned as cryptic symbols, e.g. Baden-Württemberg.

karussell commented 8 years ago

As we handle this in UTF only maybe the OCD or OSM encoding is not UTF or iso something. Do you have examples? And OCD or nominatim?

boldtrn commented 8 years ago

I have not debugged this in great detail, but when I request the following from Nominatim:

http://nominatim.openstreetmap.org/search.php?q=Kirchheimerstra%C3%9Fe%20Wernau&format=json

then the result contains:

display_name: "Kirchheimer Straße, Wernau (Neckar), Landkreis Esslingen, Regierungsbezirk Stuttgart, Baden-Württemberg, 73249, Deutschland"

When I query the geocoder converter:

http://localhost:8080/nominatim?q=Kirchheimerstra%C3%9Fe%20Wernau

then the results contain

name: "Kirchheimer Straße, Wernau (Neckar), Landkreis Esslingen, Regierungsbezirk Stuttgart, Baden-Württemberg, 73249, Deutschland
karussell commented 8 years ago

Strange, Firefox says this is already UTF8 but jersey also always uses UTF8: http://stackoverflow.com/q/9359728/194609

Maybe we need to add UTF8 here in the requests explicitly (ConverterResourceNominatim/ConverterResourceOpenCageData)? accept("application/json"). -> accept("application/json;charset=utf-8").

boldtrn commented 8 years ago

This is fixed in https://github.com/boldtrn/graphhopper-geocoder-converter/commit/a2f45fe0d9e6666359a05da43f9f2f4f8708df98

The issue was in the resource, we had to add the charset to the @Produces annotation. @Produces("application/json; charset=utf-8")

karussell commented 8 years ago

Interesting, as in the referenced stackoverflow link they say json has utf8 by default ... anyway: thanks :) !