in src/pycalendar/utils.py [0:0]
def decodeTextValue(value):
os = StringIO.StringIO()
start_pos = 0
end_pos = find_first_of(value, "\\", start_pos)
size_pos = len(value)
if end_pos != -1:
while True:
# Write current segment upto but not including the escape char
os.write(value[start_pos:end_pos])
# Bump to escapee char but not past the end
end_pos += 1
if end_pos >= size_pos:
break
# Unescape
c = value[end_pos]
if c == 'r':
os.write('\r')
elif c == 'n':
os.write('\n')
elif c == 'N':
os.write('\n')
elif c == '':
os.write('')
elif c == '\\':
os.write('\\')
elif c == ',':
os.write(',')
elif c == ';':
os.write(';')
elif c == ':':
# ":" escape normally invalid
if ParserContext.INVALID_COLON_ESCAPE_SEQUENCE == ParserContext.PARSER_RAISE:
raise ValueError("TextValue: '\\:' not allowed")
elif ParserContext.INVALID_COLON_ESCAPE_SEQUENCE == ParserContext.PARSER_FIX:
os.write(':')
# Other escaped chars normally not allowed
elif ParserContext.INVALID_ESCAPE_SEQUENCES == ParserContext.PARSER_RAISE:
raise ValueError("TextValue: '\\{}' not allowed".format(c))
elif ParserContext.INVALID_ESCAPE_SEQUENCES == ParserContext.PARSER_FIX:
os.write(c)
# Bump past escapee and look for next segment (not past the end)
start_pos = end_pos + 1
if start_pos >= size_pos:
break
end_pos = find_first_of(value, "\\", start_pos)
if end_pos == -1:
os.write(value[start_pos:])
break
else:
os.write(value)
return os.getvalue()