Thread overview |
---|
April 09, 2015 Escape a string ? | ||||
---|---|---|---|---|
| ||||
Hi ! I wonder how to escape a string in phobos ? For example auto a = [ "fooo\nbar" ]; auto b = format("%(%s%)", a); gives b: "fooo\nbar" Is there any other function to escape string? I'm looking for something that doesn't require to make an array at first. For example is there string escape(string s) in phobos ? I've searched and have not found it. |
April 09, 2015 Re: Escape a string ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | On Thursday, 9 April 2015 at 13:09:57 UTC, Temtaime wrote:
> Hi ! I wonder how to escape a string in phobos ?
> For example
>
> auto a = [ "fooo\nbar" ];
> auto b = format("%(%s%)", a);
>
> gives b: "fooo\nbar"
>
> Is there any other function to escape string? I'm looking for something that doesn't require to make an array at first.
>
> For example is there string escape(string s) in phobos ? I've searched and have not found it.
Escaping is done based on what the reserved characters are. What are you going to be using it for?
|
April 09, 2015 Re: Escape a string ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to tcak | Sorry, i meant it gives b == "fooo\\nbar" I'm writing an interpreter and it should dump original string from memory. Also i wonder if there's a function to convert "aaa\\nbb" to "aaa\nbb" (i.e. to unescape) |
Copyright © 1999-2021 by the D Language Foundation