Ask Your Question
0

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

asked 2015-06-25 19:16:34 +0200

MrMusAddict gravatar image

updated 2015-06-25 19:17:45 +0200

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?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2015-06-25 21:20:21 +0200

Alex Kemp gravatar image

updated 2015-06-25 23:52:34 +0200

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.

edit flag offensive delete link more

Comments

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

MrMusAddict gravatar imageMrMusAddict ( 2015-06-26 00:11:25 +0200 )edit
0

answered 2015-06-25 21:18:39 +0200

Lupp gravatar image

updated 2015-06-25 21:21:48 +0200

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.

edit flag offensive delete link more

Comments

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§.

rautamiekka gravatar imagerautamiekka ( 2015-06-25 21:34:12 +0200 )edit

@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.

Alex Kemp gravatar imageAlex Kemp ( 2015-06-25 21:40:21 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-06-25 19:16:34 +0200

Seen: 630 times

Last updated: Jun 25 '15