Try using backslash to escape newlines in SIL strings

thanks https://stackoverflow.com/a/54336425
This commit is contained in:
Lance Edgar 2023-09-19 15:40:29 -05:00
parent b81c33cda8
commit c94774fbb7

View file

@ -110,6 +110,10 @@ class Writer(Object):
# file. so must cleanup anything that would complicate that # file. so must cleanup anything that would complicate that
value = value.replace('\r\n', '\n') value = value.replace('\r\n', '\n')
# nb. also, if a string value does contain newlines, we must
# embed backslash to properly escape them
value = value.replace('\n', '\\\n')
value = value.replace("'", "''") value = value.replace("'", "''")
return f"'{value}'" return f"'{value}'"