On Tuesday, 22 March 2022 at 07:18:00 UTC, cc wrote:
On Sunday, 20 March 2022 at 09:42:44 UTC, Caten wrote:
Hi, I also need a function to "unquote" string, like this:
```d
assert(unquote(`\n`)=="\n");
```
Is there a way to do that?
I rolled my own for that recently:
```d
string dequote(string
On Sunday, 20 March 2022 at 09:42:44 UTC, Caten wrote:
Hi, I also need a function to "unquote" string, like this:
```d
assert(unquote(`\n`)=="\n");
```
Is there a way to do that?
I rolled my own for that recently:
```d
string dequote(string str) @safe pure {
if (str.length < 2)
On Sunday, 20 March 2022 at 09:42:44 UTC, Caten wrote:
On Sunday, 2 January 2022 at 21:16:55 UTC, Amit wrote:
On Sunday, 2 January 2022 at 19:26:50 UTC, WebFreak001 wrote:
[...]
On Sunday, 2 January 2022 at 19:37:38 UTC, JG wrote:
[...]
Yes! That's what I needed.
I wrapped it in a functio
On Sunday, 2 January 2022 at 21:16:55 UTC, Amit wrote:
On Sunday, 2 January 2022 at 19:26:50 UTC, WebFreak001 wrote:
[...]
On Sunday, 2 January 2022 at 19:37:38 UTC, JG wrote:
[...]
Yes! That's what I needed.
I wrapped it in a function like so:
```d
string quote(string s) {
return for
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:27:53 UTC, Amit wrote:
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
On Sunday, 2 January 2022 at 17:27:53 UTC, Amit wrote:
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
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
On 1/2/22 9:27 AM, Amit wrote:
> string s = "one \"two\"\nthree four";
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.
> And get as ou
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
10 matches
Mail list logo