Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waypoint name encoding utf-8 does not work #6

Closed
sebastic opened this issue Apr 22, 2024 · 9 comments
Closed

Waypoint name encoding utf-8 does not work #6

sebastic opened this issue Apr 22, 2024 · 9 comments

Comments

@sebastic
Copy link
Contributor

As reported by @flohoff in Debian Bug #1069657:

I was trying to create gpx waypoints with an utf-8 name which does not work:

perl -Mutf8 -MGeo::Gpx -e '$g=Geo::Gpx->new(); $g->waypoints_add({ lat => 0, lon => 0, name => "üöä" }); $g->save(filename => "foo.gpx");'
$ cat foo.gpx
<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" creator="Geo::Gpx" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd" xmlns="http://www.topografix.com/GPX/1/0">
<bounds maxlat="0" maxlon="0" minlat="0" minlon="0" />
<wpt lat="0" lon="0">
<name>&#xFC;&#xF6;&#xE4;</name>
</wpt>
</gpx>

The code seems to unconditionally use HTML::Entities->encode_entities

@patjoly
Copy link
Owner

patjoly commented Jun 2, 2024

Thanks for your comment.

This is the intended behaviour of the module. Many of the GPS devices using *.gpx files do not support Unicode so invoking HTML::Entities allows for the use of many accented characters in various languages.

When I open foo.gpx with GPS software (e.g. Garmin's Basecamp) and on my device, the waypoint turns up properly.

Of course, a drawback of that design is that searching waypoints based on its name with the module's methods can be trickier -- e.g. waypoint_search() -- but not breaking compatibility with devices is more important.

Capture

@flohoff
Copy link

flohoff commented Jun 2, 2024

The issue is that WHEN you open it with a utf-8 capable client its broken. For example OSMAnd.
The XML Envelope advertises utf-8, but contains only US-ASCII + HTML Encoding.

Flo

@patjoly
Copy link
Owner

patjoly commented Jun 2, 2024 via email

@flohoff
Copy link

flohoff commented Jun 3, 2024

In the original opening there is a testcase - I switched away from using Geo::Gpx because i could not work around as using HTML::Entities->encode_entities is unconditional - So i created the GPX myself using XML::TreePP

Here is the script i was creating while stumbling on the Bug.
https://github.com/flohoff/osm-fixme-to-gpx

I used to open the GPXes with OSM

https://play.google.com/store/apps/details?id=net.osmandAnd

@patjoly
Copy link
Owner

patjoly commented Jun 3, 2024

"In the original opening there is a testcase": see my reply to the opening of yesterday.

Where in the OSM interface do you open a *.gpx files? I use OSM but never opened a file with it.

@patjoly
Copy link
Owner

patjoly commented Jun 3, 2024

... from https://www.openstreetmap.org/traces I can open a Track from a *.gpx but not just waypoints. Importing results in failure when the *.gpx file has only waypoints and no tracks -- not an encoding issue, it fails with just plain characters in the name:

<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" creator="Geo::Gpx" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd" xmlns="http://www.topografix.com/GPX/1/0">
<bounds maxlat="45.405060" maxlon="-75.139486" minlat="0" minlon="0" />
<wpt lat="45.405060" lon="-75.139486">
<name>OSM_waypoint_test</name>
<time>2020-10-25T20:35:50Z</time>
</wpt>
</gpx>

@flohoff
Copy link

flohoff commented Jun 3, 2024

Not OSM/OpenStreetmap - OSMAnd - ist a Mobile App able to show GPX tracks, or use the GPX Track Waypoint as Markers.

See the link to the Android App Store.

@patjoly
Copy link
Owner

patjoly commented Jun 3, 2024 via email

@patjoly
Copy link
Owner

patjoly commented Jun 3, 2024

I just added foo.gpx in OSMAnd, works fine. I will close this issue.

2024-06-03 12 05 40

@patjoly patjoly closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants