escapeString: convert special characters in a string into their escape sequences

Version 1.1.0.0 (1.41 KB) by Christian
Escapes special characters (\r, \t, ', ...) in a string and returns the escaped string.
449 Downloads
Updated 24 May 2013

View License

Escapes special characters such as line feeds or tabs in a string and returns the escaped string. Useful for debug purposes.
Receives a string as a parameter and returns the escaped string that will reproduce the string when printing it with sprintf().
If you need to write the escape sequence using sprintf, double escaping by using
sprintf(escapeString(escapeString(str)))
or passing a single escaped string as parameter sprintf('%s',escapeString(str)) will do the trick.
Note that this function is not optimized for speed.

Cite As

Christian (2024). escapeString: convert special characters in a string into their escape sequences (https://www.mathworks.com/matlabcentral/fileexchange/41512-escapestring-convert-special-characters-in-a-string-into-their-escape-sequences), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Characters and Strings in Help Center and MATLAB Answers
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.1.0.0

Improved the description

1.0.0.0