exoscale / cs

A simple, yet powerful CloudStack API client for python and the command-line.
BSD 3-Clause "New" or "Revised" License
88 stars 36 forks source link

Encoding issue for not ASCII characters #113

Closed Kuschranini closed 1 year ago

Kuschranini commented 4 years ago

Hi all,

for me it is not possible to add a comment to a server, when the comment include not pure standard ASCII letters. For example german "umlaute" (öäü). The following issue appear:

"'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128)"

The problem is near this command line

params[k] = text_type(v)

in this file: /usr/local/lib/python2.7/dist-packages/cs/client.py I tried to fix it and set utf8 decoding before executing this code

v = v.decode("utf-8")

but this fit only for strings and not for all possible objects. So it solve the problem only in some cases not in all. For example I get this issue back:

"msg": "'bool' object has no attribute 'decode'"

This issue was recognized in version 2.5.8 and 2.7.1

The webfrontend of Cloudstack use the API and transform "Umlaute". (e.g.: ü = %C3%BC) in a UTF8 encoded form.

Sorry I don't have so much Python skills to fix this problem alone and send a PR. Could you please assist?

If you have any questions do not hesitate to ask. Thank you in advanced!

Kind regards Muschranini

brutasse commented 1 year ago

This behavior should not exhibit anymore on Python >= 3.7, and can be worked around by setting the system locale to utf-8. Closing.