Wow, several different approaches!
Thanks everyone, I find this discussion enriching.
I find `H. S. Teoh`'s template solution to be the closest to what
I need. It adds minimal complexity to the existing implementation.
Hi!
I wrote a text parser that takes a File argument and parses that
file's contents. Now I would like to write a unit-test for that
parser. I need a File (or a general IO interface) that reads from
an in-memory buffer, similar to python's `StringIO` or go's
`strings.Reader`.
How can I achi
On Sunday, 2 January 2022 at 19:26:50 UTC, WebFreak001 wrote:
as a hack I always do:
```d
writeln([s]);
```
because arrays get serialized like D strings, there will be
additional `[` and `]` though.
Sample output:
```
["Hello there \"uwu\" ``\x1B[Dabc\n"]
```
On Sunday, 2 January 2022 at 19:
On Sunday, 2 January 2022 at 17:33:22 UTC, Ali Çehreli wrote:
The issue there is that the string does not contain the two
characters \" but the single character ". So, that's a syntax
issue. The solution is to use back ticks to tell the compiler
what you really mean.
Thank you! I think my que
Hi!
I would like to print a string in the same format that I would
write it in the code (with quotes and with special characters
escaped). Similar to [Go's %q
format](https://pkg.go.dev/fmt#hdr-Printing). Is there a safe,
built-in way to do that?
For example:
```
string s = "one \"two\"\nt