I have downloaded the SHP file from the openstreetmap, and try to read the data from the shp. But when I get the attribute "name", I have no idea to decode them to Chinese. Refer to the OpenstreetMap documents, it shows that all the strings are encoded by UTF-8, but the followding code didnt' work (return the messy chars). new String(feature.getAttribute("name").toString().getBytes("UTF-8"), "gbk").

asked 07 Jun '21, 10:13

paradise099's gravatar image

accept rate: 0%

Can you explain in a bit more detail what your end goal is?

(07 Jun '21, 11:36) SomeoneElse ♦

Where are you getting a SHP file?

(08 Jun '21, 02:40) InsertUser

Download the SHP from the website: https://download.geofabrik.de

(08 Jun '21, 08:56) paradise099

I want to compare the speed of the real road data.

(08 Jun '21, 08:57) paradise099

The output when decode the name:

alt text

permanent link

answered 07 Jun '21, 10:48

paradise099's gravatar image

accept rate: 0%

edited 07 Jun '21, 10:49

Hi, I had faced a similar situation to yours. I tried to re-download the file and defined the encoding to UTF-8 in QGIS. Maybe this article will help you https://communities.bentley.com/products/hydraulics_hydrology/w/hydraulics_and_hydrologywiki/37273/characters-in-a-shapefile-do-not-appear-correctly-in-the-modelbuilder-preview (or visit communities.bentley.com and find a page 'Characters in a shapefile do not appear correctly in the ModelBuilder preview')

permanent link

answered 10 Jun '21, 07:56

zramadhanis's gravatar image

accept rate: 0%

edited 10 Jun '21, 07:59

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 07 Jun '21, 10:13

question was seen: 569 times

last updated: 10 Jun '21, 07:59

powered by OSQA