Printing a quoted string

Amit a at a.a
Sun Jan 2 17:27:53 UTC 2022


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\"\nthree four";
writeln(/* ??? */);
```

And get as output

```
"one \"two\"\nthree four"
```

Instead of

```
one "two"
three four
```


More information about the Digitalmars-d-learn mailing list