produce standard notation for strings

spir denis.spir at gmail.com
Sun Feb 13 12:13:12 PST 2011


Hello,

I need to write one or more tool functions that produce standard notation for 
strings. Something like python's repr(s). For instance:
`abc
def     "ghi" jkl`
-->
"abc\ndef\t\"ghi\" jkl"
which, fed back into D code, reproduces the original string. I have actually 
several formats in mind, depending on which class(es) of chars are conserved 
literally or not (eg only \x20..\x7f), including a hex-only one.

First, is there something like that in stock (phobos or not) and I haven't 
searched well?

Else, I wonder about the best way to do it? Use replace(), manually iterate, 
use regexes (with replace func)? What else. How would you do it?

Thank you,
Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d-learn mailing list