0

I have a dxf format file named test.dxf which has some Chinese characters inside. I tried to transform it to GeoJSON file using ogr2ogr -f GeoJSON test.geojson test.dxf and returned GeoJSON showing unrecognizable characters like this:

comp:甯岀背绉戯紙鍖椾含锛夊尰鑽鎶€鏈夐檺鍏徃"

I also tried with ogr2ogr -f GeoJSON test.geojson test.dxf ENCODING='UTF-8' but it doesn't work out.

How can I get the result correctly?

Related reference:

Converting shapefile from Shift_JIS to UTF-8 when the usual methods fail

ah bon
  • 101
  • 2
  • Do you mean that those characters are not using a correct Chinese character set? – user30184 Apr 08 '19 at 06:10
  • No, the output of transformed Chinese characters are unrecognizable messy characters. I think maybe need to set encoding configure to ogr2ogr. – ah bon Apr 08 '19 at 08:00
  • Have you read https://www.gdal.org/drv_dxf.html and what it says about character encoding? – user30184 Apr 08 '19 at 08:03
  • Yes, I just read it, please give me some advices. I have read a question's answer which says I may re-save test.dxf file with encoding utf-8 using qgis, but I hope to use command like ogr2ogr -f GeoJSON test.geojson test.dxf ENCODING='UTF-8' to transform, i'm not sure if it's possible. – ah bon Apr 08 '19 at 11:44
  • https://www.gdal.org/ogr2ogr.html – ah bon Apr 08 '19 at 12:15
  • Ogr2ogr is reading and writing data through the drivers. You have .dxf as input so the source data must be understandable for GDAL as documented in https://www.gdal.org/drv_dxf.html. You must check if you have correct codepage in ($DWGCODEPAGE). If you do not have you will fail. You may fail even if you have is correct because dxf driver is obviously most tested with ANSI 1252. Can you offer any small dxf for test data? You used an option ENCODING='UTF-8', where is it documented? – user30184 Apr 08 '19 at 12:23

1 Answers1

1

you need add DXF file encoding config,this command: "--config DXF_ENCODING". eg:

ogr2ogr --config DXF_ENCODING "UTF-8" -f GeoJSON C:\\Users\\Administrator\\Desktop\\Test.geojson C:\\Users\\Administrator\\Desktop\\Test.dxf

reference resources