collective/icalendar — Issue #24: Issue with UTF-8 encoded input
Author: kanelbulle
Created: 2012-01-16 22:18:12+00:00
State: open

Reading an ics file in UTF-8 encoding with multioctet characters in it seem to cause an **UnicodeEncodeError**:

```
Traceback (most recent call last):
File "test.py", line 7, in
print component.decoded('summary', 'none')
File "icalendar/cal.py", line 257, in decoded
return self._decode(name, value)
File "icalendar/cal.py", line 247, in _decode
decoded = types_factory.from_ical(name, value)
File "icalendar/prop.py", line 1509, in from_ical
decoded = type_class.from_ical(str(value))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 30-35: ordinal not in range(128)
```

Here's a test script with an example ics file. test.py produces the error above when run.

**test.py:**

```
from icalendar import Calendar, Event

icalstring = open('test.ics', 'r').read()

cal = Calendar.from_ical(icalstring)
for component in cal.walk():
print component.decoded('summary', 'none')
```

**test.ics:**

```
BEGIN:VCALENDAR
BEGIN:VEVENT
SUMMARY:here's some weird characters: åäöÅÄÖ
END:VEVENT
END:VCALENDAR
```

Is this intended? .ics should as far as I understand be able to handle UTF-8 unescaped. The source of the problem is at line 1509 in **prop.py**: ```decoded = type_class.from_ical(str(value))```