Problem with single quotes
John W. Eaton
jwe at bevo.che.wisc.edu
Thu Oct 2 11:31:48 CDT 2008
On 2-Oct-2008, Andreas Yankopolus wrote:
| > | > 2) The escape code for ' inside a single quoted string is ''.
| > | >
| > | > So, the following should work:
| > | > fprintf ('''')
| > |
| > | I did not know that. That statement prints a double quote in Octave.
| >
| > No, it should print a single ' character, same as Matlab.
|
| I can only report what I see. I've tried it on Octave 3.0.2 (OS X) and
| Octave 3.0.0 (Ubuntu Hardy). Both give me a double quote.
|
| > | I'll give it a shot in Matlab and see what happens.
|
| A colleague just tried it on Matlab and got a double quote as well.
Try this:
abs (sprintf (''''))
abs ('''')
Do they produce 39 (the ASCII code for ') as we would expect, or do
you get 34 (the ASCII code for ")?
You are reading the above correctly, right? That's four consecutive
single quote characters (i.e., ', ASCII 39 decimal) in the sprintf
call.
jwe
More information about the Help-octave
mailing list