LocalBitcoins / lbcapi

Simple Python library for making API calls to Localbitcoins
MIT License
97 stars 59 forks source link

UnicodeEncodeError: 'ascii' codec can't encode character '\xe1' in position 28: ordinal not in range(128) #23

Open incodemode opened 2 years ago

incodemode commented 2 years ago

Hi

When you try to block an user with special character 'á' it throws UnicodeEncodeError on line 102 of api.py. I already tried with the following transformations and none were able to actually block the user via api call:

urlsafe_username = urllib.parse.quote(username)
urlsafe_username = urllib.parse.quote_plus(username)
urlsafe_username = urllib.parse.quote_plus(username.encode())
urlsafe_username = username.encode()

this is an example

username = "KarmapaolaHernándezlopez"
response = json.loads(conn.call("POST", f"/api/feedback/{username}/", {'feedback': 'block_without_feedback'}))

is there a special way to add the username parameter without having to worry about that special character 'á'?

incodemode commented 2 years ago

Added a pull request to fix this issue: https://github.com/LocalBitcoins/lbcapi/pull/24