Single vs Double Quotes control characters plot titles

View: New views
6 Messages — Rating Filter:   Alert me  

Single vs Double Quotes control characters plot titles

by gOS :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I know GNU plot is being phased out, but I think this goes a bit deeper than GNU plot. Run both of these without jhandles and pay attention to the title:

function ptest1
  a = 1:100;
  b = 1:100;
 
  plot(a,b)
  title('This is \n a test')  
 
end

- - - - - - - - - - - - - - - - - - -

function ptest2
  a = 1:100;
  b = 1:100;
 
  plot(a,b)
  title("This is \n a test")  
 
end

- - - - - - - - - - - -

Output:
Test1

This is n a test

Test2

This is
a test

- - - - - - - - - -

I do not think using double or single quotes should have this kind of an impact on formatting, and I would consider it a bug.

Re: Single vs Double Quotes control characters plot titles

by gOS :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

gOS wrote:
I know GNU plot is being phased out, but I think this goes a bit deeper than GNU plot. Run both of these without jhandles and pay attention to the title:
I guess more to the point, since it seems you have just accepted the 'bug' upon further inspection of the documentation, how do I detect the difference between a single quote string and a double quote string?

Re: Single vs Double Quotes control characters plot titles

by Etienne Grossmann-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


  From the manual
http://www.gnu.org/software/octave/doc/interpreter/Strings.html#Strings
============================================================================
In double-quoted strings, the backslash character is used to introduce escape
sequences that represent other characters. For example, `\n' embeds a newline
character in a double-quoted string and `\"' embeds a double quote character.

In single-quoted strings, backslash is not a special character.
============================================================================

On Tue, May 13, 2008 07:32, gOS wrote:
#
# I know GNU plot is being phased out, but I think this goes a bit deeper than
# GNU plot. Run both of these without jhandles and pay attention to the title:
#
# function ptest1
#   a = 1:100;
#   b = 1:100;
#
#   plot(a,b)
#   title('This is \n a test')
#
# end
#
# - - - - - - - - - - - - - - - - - - -
#
# function ptest2
#   a = 1:100;
#   b = 1:100;
#
#   plot(a,b)
#   title("This is \n a test")
#
# end
#
# - - - - - - - - - - - -
#
# Output:
# Test1
#
# This is n a test
#
# Test2
#
# This is
# a test
#
# - - - - - - - - - -
#
# I do not think using double or single quotes should have this kind of an
# impact on formatting, and I would consider it a bug.
# --
# View this message in context:
#
http://www.nabble.com/Single-vs-Double-Quotes-control-characters-plot-titles-tp17209992p17209992.html
# Sent from the Octave - Bugs mailing list archive at Nabble.com.
#
# _______________________________________________
# Bug-octave mailing list
# Bug-octave@...
# https://www.cae.wisc.edu/mailman/listinfo/bug-octave
#


--
http://www.isr.ist.utl.pt/~etienne

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: Single vs Double Quotes control characters plot titles

by David Bateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

gOS wrote:

> gOS wrote:
>  
>> I know GNU plot is being phased out, but I think this goes a bit deeper
>> than GNU plot. Run both of these without jhandles and pay attention to the
>> title:
>>
>>    
>
> I guess more to the point, since it seems you have just accepted the 'bug'
> upon further inspection of the documentation, how do I detect the difference
> between a single quote string and a double quote string?
>  
There is no question of having the "bug accepted". As Etienne stated
this is not a bug, but the correct interpretation of escaped characters
in double quoted strings.. If you want compatible behavior with Matlab
then always use single quoted strings. As for telling if a string is
single or double quoted, the following works

octave:1> a = 'single';
octave:2> b = "double";
octave:3> typeinfo (a)
ans = sq_string
octave:4> typeinfo (b)
ans = string

or as a test

if (strcmp (typeinfo(str), "single"))
  ## Have single quoted string
else
  ## Have double quoted string
endif

D.

--
David Bateman                                David.Bateman@...
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: Single vs Double Quotes control characters plot titles

by Sergei Steshenko-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


--- David Bateman <David.Bateman@...> wrote:

> gOS wrote:
> > gOS wrote:
> >  
> >> I know GNU plot is being phased out, but I think this goes a bit deeper
> >> than GNU plot. Run both of these without jhandles and pay attention to the
> >> title:
> >>
> >>    
> >
> > I guess more to the point, since it seems you have just accepted the 'bug'
> > upon further inspection of the documentation, how do I detect the difference
> > between a single quote string and a double quote string?
> >  
> There is no question of having the "bug accepted". As Etienne stated
> this is not a bug, but the correct interpretation of escaped characters
> in double quoted strings.. If you want compatible behavior with Matlab
> then always use single quoted strings. As for telling if a string is
> single or double quoted, the following works
>
> octave:1> a = 'single';
> octave:2> b = "double";
> octave:3> typeinfo (a)
> ans = sq_string
> octave:4> typeinfo (b)
> ans = string
>
> or as a test
>
> if (strcmp (typeinfo(str), "single"))
>   ## Have single quoted string
> else
>   ## Have double quoted string
> endif
>
> D.
>
> --
> David Bateman                                David.Bateman@...
> Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
> Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
> 91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)
>

Did you actually mean

if (strcmp (typeinfo(str), "sq_string"))
  ## Have single quoted string
else
  ## Have double quoted string
endif

?

Thanks,
  Sergei.



Applications From Scratch: http://appsfromscratch.berlios.de/


     
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: Single vs Double Quotes control characters plot titles

by David Bateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sergei Steshenko wrote:

> Did you actually mean
>
> if (strcmp (typeinfo(str), "sq_string"))
>   ## Have single quoted string
> else
>   ## Have double quoted string
> endif
>
> ?
>
> Thanks,
>   Sergei.
>
>  

Opps, yes sorry

D.



--
David Bateman                                David.Bateman@...
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave