Calc: char(10) does not copy as text?

Hello,

I intended to have a spreadsheet which outputs data into a single copy-able cell, to be pasted into notepad or other text based applications.

In its simplest form, I intended something like this:

A1="Line1"
A2="Line2"
A3="Line3"
A4=A1&CHAR(10)&A2&CHAR(10)&A3

Intended output (which shows correctly within Libreoffice):

Line1
Line2
Line3

Output when A4 is copied/pasted as text:

Line1Line2Line3

Is there a way around this?

A notepad software/plain text editor on Windows will expect CHAR(13)&CHAR(10) (CR LF) for switching to the next line and make no difference as compared to a new paragraph.
A Calc cell will, however, accept the CHAR(10) ‘LF’ allone as line break for compatibility reasons on Windows, too.
Writer will accept the CHAR(10) as hard line break (not new paragraph) on any system if inserted as unformatted text. ‘New paragraph’ is CHAR(13)&CHAR(10), again. Whether you use CR,LF or LF alone in Calc won’t matter for the display. The difference will only show up in the LEN() result or on search for/preparing of the characters themselves.

Although that’s the standard just like softwares on NIX systems expect the NIX type, Notepad++ is 1 example of softwares that can toggle between all 3 (DO$, NIX and Mac Classic) for any file currently opened in it. I’m not totally sure but it seems the Nano Editor can change the type, but it seems it’s strictly limited to convert a file. Oh well, at least Linux has the §dos2unix§, §unix2dos§ and §unix2mac§ but seemingly not §dos2mac§.

@Lupp: I’ve worked with Writer under both Linux & Windows & there is zero difference between the two in behaviour on chars entered (recall that the program is reading the kbd codes, not document bytes). I programmed a large macro under Windows that (in the end) explicitly used the difference between LF + CR on entry, and during research for that macro discovered that LF is a newline under LO/OO, CR is a new paragraph & FF a new page.PDF.

Hi MrMusAddict

I take it that you are working under Windows?

In LO (this is pasting text):

lf == chr(10) == newline

cr == chr(13) == new paragraph

ff == chr(12) == new page

In Linux:

newline = lf

In Apple/Mac:

newline = cr

In Windows:

newline = lf+cr

Thus:

for standard Windows text files/editors you need chr(10)chr(13) (2 bytes) for each newline.

for standard Linux text files/editors you need chr(10) (1 byte) for each newline.

for standard Apple/Mac text files/editors you need chr(13) (1 byte) for each newline.

LO/OO, however, is different. I do not have experience of Apple/Mac, though I would expect it to be identical to Windows & Linux in which:

  • or Enter == cr == chr(13) == new paragraph
  • Shift + ↲ or Shift + Enter == lf == chr(10) == newline
  • Ctrl + ↲ or Ctrl + Enter == ff == chr(12) == new page

Very simple and, I think, rather clever.

Thank you! I replaced all char(10) with char(13)&char(10), and it is working beautifully :slight_smile: