On Thursday, 19 September 2024 at 14:30:08 UTC, Gerardo Cahn
wrote:
On Wednesday, 24 August 2022 at 08:12:33 UTC, Salih Dincer
wrote:
On Tuesday, 23 August 2022 at 23:17:21 UTC, Salih Dincer wrote:
...
Actually, both structures could be combined:
```d
struct EscapedString
{
string[1] str;
On Thursday, 19 September 2024 at 14:30:08 UTC, Gerardo Cahn
wrote:
I am using the code listed here.
It should be left to posterity that the code presented in this
thread cannot properly escape
```
"A\xfeZ"
```
```
BV's escape: cast(char) 0x41, cast(char) 0xFE, cast(char) 0x5A
steve's: c
On Wednesday, 24 August 2022 at 08:12:33 UTC, Salih Dincer wrote:
On Tuesday, 23 August 2022 at 23:17:21 UTC, Salih Dincer wrote:
...
Actually, both structures could be combined:
```d
struct EscapedString
{
string[1] str;
this(string str) @nogc pure nothrow @safe
{
...(rest clipped)
`
On Tuesday, 23 August 2022 at 23:17:21 UTC, Salih Dincer wrote:
The nice thing here is that you can change the format
specifiers as you wish.
Actually, both structures could be combined:
```d
struct EscapedString
{
string[1] str;
this(string str) @nogc pure nothrow @safe
{
this
On Tuesday, 23 August 2022 at 13:09:01 UTC, Steven Schveighoffer
wrote:
Without allocations. This took me longer than I had hoped it
would. It needs the 1-char buffer to avoid sending the
surrounding quotes.
Surely what Steve does is better. But for some reason I like
simple and useful things
On 8/23/22 6:09 AM, Bastiaan Veelo wrote:
On Thursday, 31 March 2016 at 03:15:49 UTC, cy wrote:
This might be a dumb question. How do I format a string so that all
the newlines print as \n and all the tabs as \t and such?
The easiest is this:
```d
import std.conv;
string str = `Hello "World"
On Thursday, 31 March 2016 at 03:15:49 UTC, cy wrote:
This might be a dumb question. How do I format a string so that
all the newlines print as \n and all the tabs as \t and such?
The easiest is this:
```d
import std.conv;
string str = `Hello "World"
line 2`;
writeln([str].text[2..$-2]); // He
Oh, cool.
On Thursday, 31 March 2016 at 03:29:19 UTC, H. S. Teoh wrote:
Or implement manual substitution with a pipeline:
string myString = ...;
string escapedStr = myString
.chunks(1)
.map!(c => (c == "\n") ? "\\n" :
(c
On Thursday, 31 March 2016 at 03:23:52 UTC, Seb wrote:
http://dlang.org/spec/lex.html#WysiwygString
r"ab\n" or `ab\n`
Yes I know. But I mean like,
string a = r"ab\n";
writeln(escape(a)); // => ab\n
On Thu, Mar 31, 2016 at 03:23:52AM +, Seb via Digitalmars-d-learn wrote:
> On Thursday, 31 March 2016 at 03:15:49 UTC, cy wrote:
> >This might be a dumb question. How do I format a string so that all
> >the newlines print as \n and all the tabs as \t and such?
>
> http://dlang.org/spec/lex.htm
On Thursday, 31 March 2016 at 03:15:49 UTC, cy wrote:
This might be a dumb question. How do I format a string so that
all the newlines print as \n and all the tabs as \t and such?
http://dlang.org/spec/lex.html#WysiwygString
r"ab\n" or `ab\n`
This might be a dumb question. How do I format a string so that
all the newlines print as \n and all the tabs as \t and such?
12 matches
Mail list logo