I think Richard's most excellent article CSV Must Die was alluding to that he uses VT (vertical tab - ascii 11) to escape in-text returns in his own exports, rather than this being a CSV standard or indeed anything recognised by Excel. He accurately and quite entertainingly summarises the CSV 'standard':
He goes on to propose a saner export format the he uses:When you add up all the programmer- and end-user-hours lost to dealing with the uniquely stupid collection of mish-mashed ad-hoc formats that is CSV, it amounts to nothing less than a crime against humanity.
Where by i'd guess by escape he probably means replace (but i may have misunderstood). But this doesn't solve the issue the OP poses...For my delimited exports in Fourth World products I've adopted the convention used in FileMaker Pro and others, with escapes that are unlikely to be in the data:
• records are delimited with returns
• fields delimited with tabs
• quotes are never added and are included only when they are part of the data
• any in-data returns are escaped with ASCII 11
• any in-data tabs escaped with ASCII 29
As far as i can tell, Excel uses LF (ascii 10) rather than CR (ascii 13) or CRLF to denote 'soft' returns within a cell - but it seems Excel requires some kicking to get it to do this properly... more so on Windows that on Mac (none of this is needed in Mac Excel, it will respect the double quote as a text delimiter even if this contains CR, LF or CRLF. I can only assume it has a better parser than the windows version).
If you paste:
Code: Select all
set the clipboardData to ("A" & numToNativeChar(10) & "B")
This problem not limited to LiveCode - there is a lengthy discussion on StackOverflow here: https://stackoverflow.com/questions/124 ... de-a-value
It's telling that many solutions are proposed by people still struggling... but my take-away is that Line Feed (LF - ascii 10) is key to this...