Better unicode support as per the RFC(s)
authorJames French <[email protected]>
Mon, 2 Aug 2010 08:29:31 +0000 (16:29 +0800)
committerJames French <[email protected]>
Mon, 2 Aug 2010 08:29:31 +0000 (16:29 +0800)
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

index 653d559..edfca4c 100755 (executable)
@@ -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)

UCC git Repository :: git.ucc.asn.au