pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.59k stars 200 forks source link

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' .. u'\xf6' #451

Closed k0nze closed 7 years ago

k0nze commented 8 years ago

Hello there,

I'm using khal with vdirsyncer to sync with my ownCloud. Some of the *.ics files produce errors when they are parsed by khal.

Error message:

Unknown exception happened.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/khal/khalendar/khalendar.py", line 233, in _update_vevent
    self._dbtool.update(event.raw, href=href, etag=etag)
  File "/usr/local/lib/python2.7/site-packages/khal/khalendar/backend.py", line 239, in update
    ical = icalendar.Event.from_ical(vevent_str)
  File "/usr/local/lib/python2.7/site-packages/icalendar/cal.py", line 332, in from_ical
    component.errors.append((None, str(e)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 98: ordinal not in range(128)
warning: Skipping Private/1D9A45F7-A55A-4935-9F1C-840518484435.ics: 'ascii' codec can't encode character u'\xe5' in position 98: ordinal not in range(128)
warning: This event will not be available in khal.

Corresponding *.ics file:

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//Apple Inc.//iOS 9.1//EN
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
DTSTART:19810329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
TZNAME:MESZ
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:19961027T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
TZNAME:MEZ
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20151205T145557Z
DESCRIPTION:Telefon: +46761858485
DTEND;TZID=Europe/Berlin:20160116T110000
DTSTAMP:20151205T170747Z
DTSTART;TZID=Europe/Berlin:20160115T140000
LAST-MODIFIED:20151205T170745Z
LOCATION:Hotell Centralstation\nBangårdsgatan 13 753 20 Uppsala Schweden
SEQUENCE:0
SUMMARY:Hotel: Hotell Centralstation
TRANSP:OPAQUE
UID:1D9A45F7-A55A-4935-9F1C-840518484435
URL;VALUE=URI:message://%3CE1a5EFg-000ErQ-E7%40memta-201.lhr4.prod.booking.
 com%3E?c=1449327357&k=%7Chotel%5C%7CHotell%20Centralstation%5C%7C659459422
X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=Bangårdsgatan 13 753 20 Up
 psala Schweden;X-APPLE-MAPKIT-HANDLE=CAESvAEI2TIQz4vn573d0afqARoSCfrVfi3M7
 U1AEcmsPsvspDFAIlQKCFNjaHdlZGVuEgJTRRoMVXBwc2FsYSBsw6RuMgdVcHBzYWxhOgY3NTM
 gMjBSDkJhbmfDpXJkc2dhdGFuWgIxM2IRQmFuZ8OlcmRzZ2F0YW4gMTMqEUJhbmfDpXJkc2dhd
 GFuIDEzMhFCYW5nw6VyZHNnYXRhbiAxMzIONzUzIDIwIFVwcHNhbGEyCFNjaHdlZGVuODlAAQ=
 =;X-APPLE-RADIUS=0;X-APPLE-REFERENCEFRAME=1;X-TITLE=Hotell Centralstation:
 geo:59.857794,17.644238
X-APPLE-SUGGESTION-INFO-CHANGED-FIELDS:0
X-APPLE-SUGGESTION-INFO-CHANGES-ACKNOWLEDGED:FALSE
X-APPLE-SUGGESTION-INFO-OPAQUE-KEY:|hotel\\|Hotell Centralstation\\|6594594
 22
X-APPLE-SUGGESTION-INFO-UNIQUE-KEY:|2|\\|hotel\\\\\\|Hotell Centralstation\
 \\\\\|659459422|\\|5\\|\\\\\\|1B356248-87CB-4BC7-A177-B718F4BD9488\\\\\\|<
 E1a5EFg-000ErQ-E7@memta-201.lhr4.prod.booking.com>
END:VEVENT
END:VCALENDAR

The same happens with the characters u'\xe5' and u'\xf6'

geier commented 8 years ago

Thank you for reporting this error. On first glance it looks like an error in collective/icalendar, I'll have a look ASAP. But for the time being, it should be fixed by "upgrading" to python 3 (where at least you should get a different error message).

geier commented 8 years ago

Which version of khal are you using?

k0nze commented 8 years ago

Sorry for the delay, I was on vacation. Currently I'm using version 0.8.2 installed via brew for Mac OS.

geier commented 8 years ago

Please try reinstalling under python 3, we do not support python 2 since v0.8.

geier commented 7 years ago

closed for lack of activity, please reopen if you have any new information.