pc-coholic / PyMVGLive

Python-Library to get live-data from mvg-live.de - yet another workaround the official, non-released API....
14 stars 2 forks source link

[Python3] Does not work for Stations containing non-ASCII characters #6

Closed DavidMStraub closed 8 years ago

DavidMStraub commented 8 years ago

I love this script, but unfortunately it doesn't seem to work for stations containg non-ASCII characters (such as ß or äöü, including all stations with ...straße). For all these stations, the MVG server returns

["de.swm.mvglive.gwt.client.departureView.UnknownStopNameException/2586043968","Die eingegebene Haltestelle wurde nicht gefunden!"],0,7]

I am trying this on Ubuntu 16.04 with Python 3.5.1, PyMVGLive 1.1.1.

pc-coholic commented 8 years ago

Hm, yeah... pyMVGLive and python3 are not really best friends :-(

At least for python2.x you could add

-- coding: UTF-8 --

to the beginning of your file (like for example here: https://github.com/muccc/anzeigr/blob/master/current_nodes/mvgdefas/getmvglive.py)

Regarding the general python3-issue, I'll have to look into it...

pc-coholic commented 8 years ago

The problem is apparently, how the Umlaute get converted...

In Python2.7, Görresstraße becomes 47 c3 b6 72 72 65 73 73 74 72 61 c3 9f 65 (ö = 0xC3 0xB6; ß = 0xC3 0x9F) In Python3 however, it's 47 f6 72 72 65 73 73 74 72 61 df 65 (ö = 0xF6; ß = 0xDF)

@weddige, you added some major python3-support in 6ad7894 - perhaps you have an idea, how to fix this issue easily?

DavidMStraub commented 8 years ago

Strangely enough, I found out it does work with Python 3 when I put # -*- coding: iso-8859-1 -*- at the beginning of the file. Even though that doesn't seem to make sense. With # -*- utf-8 -*- it doesn't work. When I use Python 2, I have to put either of the two (while not putting anything raises a SyntaxError).

pc-coholic commented 8 years ago

Thank you very much for your contribution! :)