Skip to content

Allow non ascii characters to be encoded using Base64 #194

Description

>>> tracker.track_self_describing_event(SelfDescribingJson("iglu:com.acme/self_desc/jsonschema/1-0-0", {"accénted_cháráctêrs": "accénted_cháráctêrs"}))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 2, in track_unstruct_event
  File "/usr/local/lib/python3.4/dist-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/snowplow_tracker/tracker.py", line 621, in track_unstruct_event
    pb.add_json(envelope, self.encode_base64, "ue_px", "ue_pr")
  File "<string>", line 2, in add_json
  File "/usr/local/lib/python3.4/dist-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/snowplow_tracker/payload.py", line 85, in add_json
    encoded_dict = base64.urlsafe_b64encode(json_dict.encode("ascii"))
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 23: ordinal not in range(128)

I'm not being able to pass accented characters through the Python tracker with base64 enabled. Any ideas of a workaround?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions