disp and fprintf, a possible bug...?

John W. Eaton jwe at bevo.che.wisc.edu
Tue Feb 19 13:17:03 CST 2008


On 19-Feb-2008, Vlatko Be?anovi? wrote:

| ..please see the attached file for more info.
| To: bug at octave.org
| Cc: vlatko.becanovic at tobii.com
| Subject: disp and printf - problems displaying ascii special characters
| --------
| Bug report for Octave 2.9.9 configured for i486-pc-linux-gnu
| 
| Description:
| -----------

| Problem 1: disp() ignores the special ascii character line feed (and perhaps also others)

Precisely how are you using disp?  If it is

  disp ('\n')

and you see

  \n

displayed, then it is working correctly.  Note that '\n' is not a
linefeed character, but the two characters '\' and 'n'.  If you want a
linefeed character, you need to write "\n" or sprintf ('\n').


| Problem 2: printf() treats strings concatenated from cell array elements differently!
| 
| Repeat-By:
| ---------
| 
| % String concatenated from cell array elements, e.g. s0 = {d{1},d{2},... }
| 
| octave:485> s0(3:5)
| ans = '\n'
| 
| % String created at command prompt, e.g. s1 = 'P5\n#Created by Coriander\n'
| 
| octave:486> s1(3:5)
| ans = '\n'
| 
| % Problem start here.... 
| 
| octave:487> printf(s0)
| P5\n#Created by Coriander\n

Precisely what is in your cell array d?

It's best to send a single bug report for each problem you find rather
than combining them into a single message.

jwe


More information about the Bug-octave mailing list