Language problem

I read my routing information from shape file .
the language of shape file is Persian and its encoding is UTF-8.
when i open it by QGIS the font and language is correct.
But when i get this information in intellij idea, the font is disorder and bad formatting.
when i open the names file that is created by graphhopper, it has problem too

Can you guide me how can i correct the language?

Best Regards

This is a current limitation of the shape reader. The problem is that the shp file has no info about the encoding (or was it a limitation of geotools library that we use @PGWelch? )

Maybe you try a workaround and use the JVM setting -Dfile.encoding=utf8 and see if this helps?

Basically we use the Geotools library for reading the shapefile, and that has poor support for different characters sets (largely because shapefiles themselves have poor support for it). Although it’s not 100% clear, it doesn’t look like Geotools shapefile reader supports the .cpg file which you can use to set the character set “codepage” (see discussion here ). There would probably need to be either some software development done on the shapefile reader or on Geotools itself to properly handle Persian characters.

The links mentions “I think you need to provide the correct charset connection parameter”. This is also mentioned here

If you are working with Arabic, Chinese or Korean character sets you will need to make use of the “charset” connection parameter when setting up your shapefile

You’d probably need to modify this file in the method openShapefileDataStore I believe, when it opens the shapefile.

In an ideal world, Geotools should actually read the cpg file (which is probably what QGIS does?) and then it would just work automatically (assuming you have a cpg file).

1 Like

Thanks for your helpful answer.

When i add "map.put(“charset”, “utf8”); " to method "openShapefileDataStore"
the problem was solved.

Best Regards

1 Like

Better have the .dbf encoding passed as option in shp reader?
Or default could be utf-8?

@sh.attarha cool, thanks for letting us know - will create an issue for this! And and yes, as @devemux86 said we should make this the default (and maybe configurable)