[GIS] How to get the mapserver WFS OGR driver to encode unicode in geojson

gdalgeojsonmapserverogrunicode

Running mapserver 6.4.1, gdal 1.14.3 I try to output some WFS features using outputformat=geojson. The relevant bits of the mapfile are appended below.

Everything works fine, but unicode characters are still encoded as ISO-8859-1 when using geojson. The OGR/GML driver outputs utf-8 correctly. OGR/CSV also fails and uses ISO-8859-1.

I get for example "gatenavn": "Langørhøgden" with outputformat=geojson and <ms:gatenavn>Langørhøgden</ms:gatenavn> in GML

Is there any dataset or layer creation option or mapfile parameter I am missing?

 (in WEB/METADATA)
 "wfs_getfeature_formatlist" "geojson,csv,ogrgml"
 "wfs_encoding" "UTF-8"


 OUTPUTFORMAT
  NAME "geojson"
  DRIVER "OGR/GEOJSON"
  MIMETYPE "application/json; subtype=geojson"
  FORMATOPTION "STORAGE=stream"
  FORMATOPTION "FORM=SIMPLE"
  FORMATOPTION "LCO:COORDINATE_PRECISION=5"
 END

Best Answer

Turns out it is as easy as this:

MIMETYPE "application/json; subtype=geojson; charset=utf-8"

Without the setting, no content encoding is returned by the server.

Related Question