Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3e60ff9d4d6f58c8fbd17208f14089fa > files > 172

octave-doc-3.2.3-3mdv2010.0.i586.rpm

<html lang="en">
<head>
<title>Escape Sequences in string constants - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Strings.html#Strings" title="Strings">
<link rel="next" href="Character-Arrays.html#Character-Arrays" title="Character Arrays">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Escape-Sequences-in-string-constants"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Character-Arrays.html#Character-Arrays">Character Arrays</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Strings.html#Strings">Strings</a>
<hr>
</div>

<h3 class="section">5.1 Escape Sequences in string constants</h3>

<p><a name="index-escape-sequence-notation-283"></a>In double-quoted strings, the backslash character is used to introduce
<dfn>escape sequences</dfn> that represent other characters.  For example,
&lsquo;<samp><span class="samp">\n</span></samp>&rsquo; embeds a newline character in a double-quoted string and
&lsquo;<samp><span class="samp">\"</span></samp>&rsquo; embeds a double quote character.  In single-quoted strings, backslash
is not a special character.  Here is an example showing the difference:

<pre class="example">     toascii ("\n")
         &rArr; 10
     toascii ('\n')
         &rArr; [ 92 110 ]
</pre>
   <p>Here is a table of all the escape sequences used in Octave (within
double quoted strings).  They are the same as those used in the C
programming language.

     <dl>
<dt><code>\\</code><dd>Represents a literal backslash, &lsquo;<samp><span class="samp">\</span></samp>&rsquo;.

     <br><dt><code>\"</code><dd>Represents a literal double-quote character, &lsquo;<samp><span class="samp">"</span></samp>&rsquo;.

     <br><dt><code>\'</code><dd>Represents a literal single-quote character, &lsquo;<samp><span class="samp">'</span></samp>&rsquo;.

     <br><dt><code>\0</code><dd>Represents the &ldquo;nul&rdquo; character, control-@, ASCII code 0.

     <br><dt><code>\a</code><dd>Represents the &ldquo;alert&rdquo; character, control-g, ASCII code 7.

     <br><dt><code>\b</code><dd>Represents a backspace, control-h, ASCII code 8.

     <br><dt><code>\f</code><dd>Represents a formfeed, control-l, ASCII code 12.

     <br><dt><code>\n</code><dd>Represents a newline, control-j, ASCII code 10.

     <br><dt><code>\r</code><dd>Represents a carriage return, control-m, ASCII code 13.

     <br><dt><code>\t</code><dd>Represents a horizontal tab, control-i, ASCII code 9.

     <br><dt><code>\v</code><dd>Represents a vertical tab, control-k, ASCII code 11.

     <!-- We don't do octal or hex this way yet. -->
     <!-- @item \@var{nnn} -->
     <!-- Represents the octal value @var{nnn}, where @var{nnn} are one to three -->
     <!-- digits between 0 and 7.  For example, the code for the ASCII ESC -->
     <!-- (escape) character is @samp{\033}.@refill -->
     <!-- @item \x@var{hh}@dots{} -->
     <!-- Represents the hexadecimal value @var{hh}, where @var{hh} are hexadecimal -->
     <!-- digits (@samp{0} through @samp{9} and either @samp{A} through @samp{F} or -->
     <!-- @samp{a} through @samp{f}).  Like the same construct in @sc{ansi} C, -->
     <!-- the escape -->
     <!-- sequence continues until the first non-hexadecimal digit is seen.  However, -->
     <!-- using more than two hexadecimal digits produces undefined results.  (The -->
     <!-- @samp{\x} escape sequence is not allowed in @sc{posix} @code{awk}.)@refill -->
   </dl>

   <p>In a single-quoted string there is only one escape sequence: you may insert a
single quote character using two single quote characters in succession.  For
example,

<pre class="example">     'I can''t escape'
         &rArr; I can't escape
</pre>
   </body></html>