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

Character encoding issues with GPX #74

Closed
alexander-klump opened this issue Dec 19, 2023 · 5 comments
Closed

Character encoding issues with GPX #74

alexander-klump opened this issue Dec 19, 2023 · 5 comments
Labels
type: bug Something isn't working

Comments

@alexander-klump
Copy link

Hallo, heute wollte ich das Programm auf Windows testen. Das Ausführen von start.bat sieht bei mir so aus:

2023-12-19 23:47:42 geo_activity_playground.core.cache_migrations INFO Apply cache migration if needed …
2023-12-19 23:47:42 geo_activity_playground.core.config WARNING Missing a config, some features might be missing.
Parse activity files:  75%|██████████████████████████████████████████████▌               | 3/4 [00:00<00:00, 95.87it/s]
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\__main__.py", line 117, in <module>
    main()
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\__main__.py", line 92, in main
    options.func(options)
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\__main__.py", line 67, in <lambda>
    make_activity_repository(options.basedir),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\__main__.py", line 100, in make_activity_repository
    import_from_directory()
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\importers\directory.py", line 41, in import_from_directory
    timeseries = read_activity(path)
                 ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\core\activity_parsers.py", line 30, in read_activity
    df = read_gpx_activity(path, opener)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\geo_activity_playground\core\activity_parsers.py", line 127, in read_gpx_activity
    gpx = gpxpy.parse(f)
          ^^^^^^^^^^^^^^
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\gpxpy\__init__.py", line 37, in parse
    parser = mod_parser.GPXParser(xml_or_file)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\gpxpy\parser.py", line 70, in __init__
    self.init(xml_or_file)
  File "C:\Users\alexa\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\gpxpy\parser.py", line 82, in init
    text = xml_or_file.read() if hasattr(xml_or_file, 'read') else xml_or_file # type: ignore
           ^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 345: character maps to <undefined>

C:\Users\alexa\OneDrive\Documents\GeoActivityPlayground>pause
Drücken Sie eine beliebige Taste . . .
@alexander-klump
Copy link
Author

Ich habe das Problem gefunden: Schuld war eine Datei mit dem Namen "2023-07-22_1224230809_Von Lozen nach в.з. Долни Пасарел.gpx". Vielleicht waren die kyrillischen Buchstaben das Problem.

@martin-ueding
Copy link
Owner

Danke für den Bericht! Das ist doch durchaus ein Bug, derartige Dateien sollten schon gelesen werden können. Jemand anderes hat das gleiche auch per E-Mail berichtet. Ich habe auch schon eine Idee, was das Problem sein könnte.

@martin-ueding martin-ueding reopened this Dec 20, 2023
@martin-ueding martin-ueding added the type: bug Something isn't working label Dec 20, 2023
@martin-ueding
Copy link
Owner

Kannst du mal mit Version 0.15.2 ausprobieren, ob der Fehler noch immer besteht?

@alexander-klump
Copy link
Author

mit Version 0.15.2 funktioniert es. Woran lag es?

@martin-ueding
Copy link
Owner

Python scheint sich auf dem jeweiligen System ein Encoding für Sonderzeichen zu suchen, das zur ausgewählten Sprache passt. Das ist aber nicht mehr zeitgemäß, inzwischen nutzt alles UTF-8. Zusätzlich wollen wir auch gar nicht den Text lesen, sondern nur die Zahlen in den Dateien.

Ich öffne die Dateien jetzt im Binärmodus, also ohne den Text zu interpretieren. Und damit kommt es nicht mehr zu einer falschen Interpretation von Sonderzeichen.

@martin-ueding martin-ueding changed the title Fehler beim Ausführen in Windows Character encoding issues with GPX Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants