joshvillbrandt / wireless

A dead simple, cross-platform Python library to connect to wireless networks.
https://pypi.org/project/wireless/
Apache License 2.0
83 stars 42 forks source link

Wireless.py cannot parse wireless network names with Unicode characters #19

Open spiritphyz opened 7 years ago

spiritphyz commented 7 years ago

Hi,

My wireless network has an Emoji in it:

$ /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I \
>   | grep " SSID"
           SSID: 🐳 Big Whale Network

This seems to break Wireless.py's parsing for the wireless name? Some suggested possible fixes include setting "utf-8" for the decode() call or having the regex match more than ASCII characters?

The error is below (I'm on macOS 10.12.2 and Python 2.7.12):

File "/usr/local/lib/python2.7/site-packages/wireless/Wireless.py", line 11, in cmd
    stdout=subprocess.PIPE, stderr=subprocess.STDOUT
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 23: ordinal not in range(128)

@tbodt @kylemcdonald reference: https://github.com/kylemcdonald/FreeWifi/issues/13#issuecomment-279052108

tbodt commented 7 years ago

The regex indicated is unrelated to the problem, it's only for extracting the version number of nmcli which is only useful on Ubuntu.

tbodt commented 7 years ago

I don't know if there is a standard encoding for wifi names, if there is it should be used instead of utf8.