On Friday, 16 May 2025 at 09:42:20 UTC, Kagamin wrote:
On Wednesday, 14 May 2025 at 11:38:59 UTC, Nick Treleaven wrote:
So `to!string` is bad for generic code. Want to represent the
address of a byte* as hex in a string, fine. Oh now the
pointer's element type is char - wait, why isn't the resu
On Wednesday, 14 May 2025 at 11:38:59 UTC, Nick Treleaven wrote:
So `to!string` is bad for generic code. Want to represent the
address of a byte* as hex in a string, fine. Oh now the
pointer's element type is char - wait, why isn't the result hex
any more?
try `to!(string,void*)`?
On Wednesday, 14 May 2025 at 11:38:59 UTC, Nick Treleaven wrote:
On Wednesday, 14 May 2025 at 03:36:40 UTC, Jonathan M Davis
wrote:
to!string definitely deals with null-terminated strings, or it
wouldn't work at all. It's not the kind of thing that would
work by accident.
I don't think it's g
On Wednesday, May 14, 2025 5:38:59 AM Mountain Daylight Time Nick Treleaven via
Digitalmars-d-learn wrote:
> On Wednesday, 14 May 2025 at 03:36:40 UTC, Jonathan M Davis wrote:
> > to!string definitely deals with null-terminated strings, or it
> > wouldn't work at all. It's not the kind of thing th
On Wednesday, 14 May 2025 at 03:36:40 UTC, Jonathan M Davis wrote:
to!string definitely deals with null-terminated strings, or it
wouldn't work at all. It's not the kind of thing that would
work by accident.
I don't think it's good API design:
Pointer to string conversions convert the pointer
On Wednesday, May 7, 2025 10:51:27 PM Mountain Daylight Time Andy Valencia via
Digitalmars-d-learn wrote:
> On Thursday, 8 May 2025 at 00:53:20 UTC, Mike Parker wrote:
> >> tst44.d(6): Error: cannot implicitly convert expression
> >> `fromStringz(ctime(null))` of type `char[]` to `string`
> > `fro
On Thursday, 8 May 2025 at 04:51:27 UTC, Andy Valencia wrote:
Thank you. I want to work in strings, so the first one's not
an option. But both the second and third do the trick. Would
you say the to!string would be the most idiomatic? It worked
as "to!string(ctime(&t))", but is it safe to
On Thursday, 8 May 2025 at 00:53:20 UTC, Mike Parker wrote:
tst44.d(6): Error: cannot implicitly convert expression
`fromStringz(ctime(null))` of type `char[]` to `string`
`fromStringz` is giving you a slice of a `char*`, typed
`char[]`.
`string` is `immutable(char)[]`, so you can't assign `ch
On Wednesday, 7 May 2025 at 22:47:35 UTC, Andy Valencia wrote:
So about fromStringz...
```d
import std.string : fromStringz;
import core.stdc.time : ctime;
void
main() {
string s = fromStringz(ctime(null));
}
```
Like that?
tst44.d(6): Error: cannot implicitly convert expression
`fromSt
On Wednesday, 7 May 2025 at 22:28:32 UTC, Dejan Lekic wrote:
https://dlang.org/library/std/string/from_stringz.html
So about fromStringz...
```d
import std.string : fromStringz;
import core.stdc.time : ctime;
void
main() {
string s = fromStringz(ctime(null));
}
```
Like that?
tst44.d(6)
On Wednesday, 7 May 2025 at 22:28:32 UTC, Dejan Lekic wrote:
https://dlang.org/library/std/string/from_stringz.html
Given that `fromStringz` returns a slice of the original string,
you can use `std.conv.to` to do it with an allocation when
needed: `to!string(str)`.
On Wednesday, 7 May 2025 at 22:23:36 UTC, Andy Valencia wrote:
Now I want it to be a D string. What's the right way to do
this? Performance and memory use are not important; I just
want a simple and idiomatic way to get from point A to point B.
https://dlang.org/library/std/string/from_strin
12 matches
Mail list logo