changeset 16763:70ea511edbc4

strjoin.m: delimiter can include escape sequences (matlab compatibility)
author Stefan Mahr <dac922@gmx.de>
date Sun, 16 Jun 2013 12:07:19 +0200
parents 42555422e326
children 532ccee1b6f5
files scripts/strings/strjoin.m
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/strings/strjoin.m	Sat Jun 15 17:40:14 2013 -0400
+++ b/scripts/strings/strjoin.m	Sun Jun 16 12:07:19 2013 +0200
@@ -27,11 +27,12 @@
 ## seperated by a space.
 ##
 ## If @var{delimiter} is specified as a string, the cell-string array is
-## joined using the string.
+## joined using the string. Escape sequences are supported.
 ##
 ## If @var{delimiter} is a cell-string array whose length is one less
 ## than @var{cstr}, then the elemennts of @var{cstr} are joined by
-## interleaving the cell-string elements of @var{delimiter}.
+## interleaving the cell-string elements of @var{delimiter}. Escape
+## sequences are not supported.
 ##
 ## @example
 ## @group
@@ -58,6 +59,7 @@
   endif
 
   if (ischar (delimiter))
+    delimiter = do_string_escapes (delimiter);
     delimiter = {delimiter};
   end
  
@@ -82,3 +84,5 @@
 %!  "Octave*Scilab*Lush*Yorick")
 %!assert (strjoin ({"space", "comma", "dash", "semicolon", "done"},
 %!  {" ", ",", "-", ";"}), "space comma,dash-semicolon;done")
+%!assert (strjoin ({'Octave','Scilab'},'\n'), "Octave\nScilab")
+%!assert (strjoin ({'Octave','Scilab'},{'\n'}), "Octave\\nScilab")