time | Calls | line |
---|
| | 1 | function str = strescape(str)
|
| | 2 | %STRESCAPE Escape control character sequences in a string.
|
| | 3 | % STRESCAPE(STR) converts the escape sequences in a string to the values
|
| | 4 | % they represent.
|
| | 5 | %
|
| | 6 | % Example:
|
| | 7 | %
|
| | 8 | % strescape('Hello World\n')
|
| | 9 | %
|
| | 10 | % See also SPRINTF.
|
| | 11 |
|
| | 12 | % Copyright 2012-2015 The MathWorks, Inc.
|
| | 13 |
|
< 0.001 | 2 | 14 | if iscell(str)
|
| | 15 | str = cellfun(@(c)strescape(c), str, 'UniformOutput', false);
|
< 0.001 | 2 | 16 | else
|
< 0.001 | 2 | 17 | idx = 1;
|
| | 18 | % Note that only [1:end-1] of the string is checked,
|
| | 19 | % since unescaped trailing backslashes are ignored.
|
< 0.001 | 2 | 20 | while idx < length(str)
|
| | 21 | if str(idx) == '\'
|
| | 22 | str(idx) = []; % Remove the '\' escape character itself.
|
| | 23 | str(idx) = escapeChar(str(idx));
|
| | 24 | end
|
| | 25 | idx = idx + 1;
|
| | 26 | end
|
< 0.001 | 2 | 27 | end
|
| | 28 |
|
< 0.001 | 2 | 29 | end
|
Other subfunctions in this file are not included in this listing.