From c973d20ef57023dc0994d7ffeb0a6e1fd6f9eb0f Mon Sep 17 00:00:00 2001 From: James French Date: Mon, 2 Aug 2010 16:29:31 +0800 Subject: [PATCH] Better unicode support as per the RFC(s) Will unfold lines and then treat them as UTF-8. Before folding lines, they're converted to 8-bit strings and split at 75 octets. --- icalparse.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/icalparse.py b/icalparse.py index 653d559..edfca4c 100755 --- a/icalparse.py +++ b/icalparse.py @@ -41,7 +41,7 @@ def lineJoiner(oldcal): oldcal = '\r\n'.join(oldcal) oldcal = oldcal.replace('\r\n ', '').replace('\r\n\t','') - return oldcal.strip().split('\r\n') + return [unicode(x, 'utf-8') for x in oldcal.strip().split('\r\n')] def lineFolder(oldcal, length=75): @@ -54,6 +54,7 @@ def lineFolder(oldcal, length=75): sl = length - 1 for line in oldcal: + line = line.encode('utf-8') # Line fits inside length, do nothing if len(line.rstrip()) <= length: cal.append(line) -- 2.20.1