calvinmetcalf / shapefile-js

Convert a Shapefile to GeoJSON. Not many caveats.
http://calvinmetcalf.github.io/shapefile-js/
715 stars 228 forks source link

Coding problem #80

Closed zhangziyi123 closed 2 years ago

zhangziyi123 commented 7 years ago

There is a problem in Chinese;If the attribute value is Chinese, there will be a problem with the Chinese language

calvinmetcalf commented 7 years ago

checkout the new version I just published though see the note in the readme about IE

On Fri, Jun 9, 2017 at 3:00 AM service notifications@github.com wrote:

There is a problem in Chinese;If the attribute value is Chinese, there will be a problem with the Chinese language

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/calvinmetcalf/shapefile-js/issues/80, or mute the thread https://github.com/notifications/unsubscribe-auth/ABE4n5DJmNLoZuR20dtouw1eTGI2j0-8ks5sCO14gaJpZM4N0-Wc .

wxia5 commented 6 years ago

I' m having same issue here,Chinese character is not encoded correctly and I am using Chrome. What else steps are needed to display them correctly?Thanks.

calvinmetcalf commented 6 years ago

have you tried the nw version @wxia5 ?

wxia5 commented 6 years ago

yes,I am using the gh-page branch and still no luck. However, I find this link works for me. link It works fine for my data which is encoded in gb2312. Hope it helps a little bit. Regards.

K0den commented 6 years ago

@calvinmetcalf I think the problem is here https://github.com/calvinmetcalf/shapefile-js/blob/gh-pages/lib/index.js#L93

parseDbf takes buffer and encoding. That line is giving it buffer and undefined.

K0den commented 6 years ago

@fix in #95

argoo83 commented 5 years ago

I am using the latest version of this library. And parseing a shp-file

Observable.forkJoin([ Observable.fromEvent(shpReader, 'loadend').first(), Observable.fromEvent(dbfReader, 'loadend').first() ]).subscribe(res => { let geoJson = shp.combine([shp.parseShp(shpReader.result), shp.parseDbf(dbfReader.result)]) }); shpReader.readAsArrayBuffer(shpFile.shp); dbfReader.readAsArrayBuffer(shpFile.dbf);

My attributevalues contains swedish chars and i can't manage to get them in right encoding. Any tips?

calvinmetcalf commented 5 years ago

shp.parseDbf(dbfReader.result) can take as a second argument the encoding, aka the contents of the .cpg file

quyihang commented 5 years ago

I got the same problem. The shp file created by ArcGIS doesn't contain cpg, while the Chinese characters are encoded by GBK. Then I use QGIS to edit the files, it works. 使用QGIS生成的shp可以在这个插件下正常使用。