NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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

paradise099
11113
accept rate: 0%

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

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

Where are you getting a SHP file?

(08 Jun '21, 02:40) InsertUser
1

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

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

zramadhanis
11
accept rate: 0%

edited 10 Jun '21, 07:59

The output when decode the name:

alt text

permanent link

answered 07 Jun '21, 10:48

paradise099's gravatar image

paradise099
11113
accept rate: 0%

edited 07 Jun '21, 10:49

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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:

×2
×1

question asked: 07 Jun '21, 10:13

question was seen: 796 times

last updated: 10 Jun '21, 07:59

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum