From: James French Date: Mon, 2 Aug 2010 08:29:31 +0000 (+0800) Subject: Better unicode support as per the RFC(s) X-Git-Tag: 0.7.1~2 X-Git-Url: https://git.ucc.asn.au/?p=frenchie%2Ficalparse.git;a=commitdiff_plain;h=c973d20ef57023dc0994d7ffeb0a6e1fd6f9eb0f;hp=763fc87a8fc530dc8ecfa1d8f0c9fd2b70b5ab3c 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. --- 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)