On Friday, 31 December 2021 at 14:45:41 UTC, Steven Schveighoffer
wrote:
Unless I'm misunderstanding:
```d
import std.algorithm : until;
writefln("got '%s' from '%s:%d'",
(cast(char[])ioCtx.buf[]).until('\n'), client.addr,
client.port);
```
```d
import std.stdio;
import std.string;
void m
On Saturday, 1 January 2022 at 09:34:10 UTC, Jack Applegame wrote:
On Thursday, 30 December 2021 at 18:07:15 UTC, eugene wrote:
On Thursday, 30 December 2021 at 17:52:20 UTC, eugene wrote:
much better than my initial
You can also write
```d
auto s = cast(string)b; // or cast(string)(b)
```
ins
On Sunday, 2 January 2022 at 08:39:57 UTC, eugene wrote:
```d
import std.stdio;
import std.string;
```
oops...
```d
import std.stdio;
import std.string;
import std.algorithm : until;
void main() {
ubyte[8] b = [0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x0A, 0x00, 0x00];
/* "hello\n\0\0" */
w
On Sunday, 2 January 2022 at 09:15:32 UTC, eugene wrote:
```
p1.d(9): Error: cannot cast expression `until(b[], '\x0a',
Flag.yes)` of type `Until!("a == b", ubyte[], char)` to `char[]`
```
Here's a working version:
```d
import std.stdio;
import std.string;
import std.algorithm : until, map
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
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
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 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 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 1/2/22 4:15 AM, eugene wrote:
On Sunday, 2 January 2022 at 08:39:57 UTC, eugene wrote:
```d
import std.stdio;
import std.string;
```
oops...
```d
import std.stdio;
import std.string;
import std.algorithm : until;
void main() {
ubyte[8] b = [0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x0A, 0x00, 0
11 matches
Mail list logo