I have a problem regarding Leaflet and calvinmetcalf's shapefile module. In my shapefile I have fields and in those fields are strings like:


You see that due to the special characters in the shapefile fields, on my Leaflet I get strange outputs. I think that is due to the UTF-8 restrictions. Since my data is not loaded on a regular webpage using a .html file, but using a Sharepoint webpart, how on earth can I show the special characters? For sure, I added above the <meta charset="utf-8"/>. Am I missing something?

  • 1
    You'll need to provide more information - how does the output look like and, if possible, details about the encoding of the shapefile text (do you have a .cpg sidecar file?). Utilities like ogrinfo (gdal.org/programs/ogrinfo.html#ogrinfo) will display that kind of metadata from the shapefile. – IvanSanchez Jun 10 at 17:07

utf-8 can display pretty much anything - characters up to 4 bytes gives, as you probably know, about 4 billion possible characters. In fact, utf-8 is about the least restrictive character set there is (hence the wide use).

"strange outputs" is a poor substitute for a screenshot, but there are a few things worth checking:

  1. Is the input data (the shapefile) in utf-8?
  2. Does the shapefile display correctly in, eg qgis/openlayers/whatever else is handy?
  3. What characters are actually being parsed from the Shapefile (ie via console.log())
  4. Does the font you are using have glyphs for those special characters

If it were me, I'd go for #2 first and use that to do #1 if I could do it in 5 minutes or less, and then move to #3, which should give you some insight on #4.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.