On Friday, 2 April 2021 at 15:01:07 UTC, mw wrote:
BTW, shall I log a writeln() improvement bug ?
It's really confusing, e.g as debug print or logs.
In my opinion this isn't a bug. The nulls are actually printed:
```
$> rdmd test.d | hd
61 62 63 00 00 00 36 0a 68 65 61 64 2d 61 62
On Friday, 2 April 2021 at 05:02:52 UTC, mw wrote:
On Friday, 2 April 2021 at 04:54:07 UTC, Computermatronic wrote:
On Friday, 2 April 2021 at 04:49:22 UTC, mw wrote:
So you mean inside the writeln() call, the 0s are skipped?
Well, if I use `string t` as filename, it will try to looking
for a
On Friday, 2 April 2021 at 05:39:26 UTC, mw wrote:
Finally, I'm using:
https://run.dlang.io/is/651lT6
string t = text("head-", s[].until('\0').array, "-tail");
FYI, you don't need the call to `.array` there--`text` accepts
input ranges.
On Friday, 2 April 2021 at 05:18:49 UTC, H. S. Teoh wrote:
On Fri, Apr 02, 2021 at 05:05:21AM +, mw via
Digitalmars-d-learn wrote: [...]
This is just an example, what if the exact length is not known
statically, is there a functions to trim the `\0`s?
What about `s.until('\0')`?
Example:
On Friday, 2 April 2021 at 04:32:53 UTC, mw wrote:
https://run.dlang.io/is/B4jcno
---
import std;
import std.conv : text;
void main()
{
char[6] s;
s = "abc";
writeln(s, s.length); // abc6, ok it's the static array's
length
string t = text("head-", s, "-tail");
writeln(t
On 02/04/2021 6:10 PM, Computermatronic wrote:
On Friday, 2 April 2021 at 05:02:52 UTC, mw wrote:
Ahh, I got what I see (from writeln) is not what get string here ;-)
And I just tried:
string t = text("head-", strip(s), "-tail");
It's the same behavior.
So how can I trim the leading & trai
On Fri, Apr 02, 2021 at 05:05:21AM +, mw via Digitalmars-d-learn wrote:
[...]
> This is just an example, what if the exact length is not known
> statically, is there a functions to trim the `\0`s?
Another way, if you want to avoid the extra allocation, slice the static
array with .indexOf:
On Fri, Apr 02, 2021 at 05:05:21AM +, mw via Digitalmars-d-learn wrote:
[...]
> This is just an example, what if the exact length is not known
> statically, is there a functions to trim the `\0`s?
What about `s.until('\0')`?
Example:
auto s = "abc\0\0\0def";
auto t = "blah" ~
On Friday, 2 April 2021 at 05:02:52 UTC, mw wrote:
Ahh, I got what I see (from writeln) is not what get string
here ;-)
And I just tried:
string t = text("head-", strip(s), "-tail");
It's the same behavior.
So how can I trim the leading & trailing `\0` from the static
char array?
strip on
On Friday, 2 April 2021 at 05:01:27 UTC, rikki cattermole wrote:
On 02/04/2021 5:51 PM, mw wrote:
Then how can I construct `t`? to make this assertion true:
assert(t == "head-abc-tail"); // failed!
Slice it.
string t = text("head-", s[0 .. 3], "-tail");
http://ddili.org/ders/d.en/slic
On 02/04/2021 5:51 PM, mw wrote:
Then how can I construct `t`? to make this assertion true:
assert(t == "head-abc-tail"); // failed!
Slice it.
string t = text("head-", s[0 .. 3], "-tail");
http://ddili.org/ders/d.en/slices.html
On Friday, 2 April 2021 at 04:54:07 UTC, Computermatronic wrote:
On Friday, 2 April 2021 at 04:49:22 UTC, mw wrote:
So you mean inside the writeln() call, the 0s are skipped?
Well, if I use `string t` as filename, it will try to looking
for a file called:
"head-abc\0\0\0-tail" instead of jus
On Fri, Apr 02, 2021 at 04:32:53AM +, mw via Digitalmars-d-learn wrote:
[...]
> ---
> import std;
> import std.conv : text;
>
>
> void main()
> {
> char[6] s;
> s = "abc";
> writeln(s, s.length); // abc6, ok it's the static array's length
>
> string t = text("head-", s, "-ta
On Friday, 2 April 2021 at 04:49:22 UTC, mw wrote:
On Friday, 2 April 2021 at 04:43:48 UTC, rikki cattermole wrote:
On 02/04/2021 5:38 PM, mw wrote:
On Friday, 2 April 2021 at 04:36:01 UTC, rikki cattermole
wrote:
On 02/04/2021 5:32 PM, mw wrote:
---
import std;
import std.conv : text;
void
On Friday, 2 April 2021 at 04:49:22 UTC, mw wrote:
So you mean inside the writeln() call, the 0s are skipped?
Well, if I use `string t` as filename, it will try to looking
for a file called:
"head-abc\0\0\0-tail" instead of just "head-abc-tail" ?
or it's platform dependent?
I would imagine
On Friday, 2 April 2021 at 04:43:48 UTC, rikki cattermole wrote:
On 02/04/2021 5:38 PM, mw wrote:
On Friday, 2 April 2021 at 04:36:01 UTC, rikki cattermole
wrote:
On 02/04/2021 5:32 PM, mw wrote:
---
import std;
import std.conv : text;
void main()
{
char[6] s;
s = "abc";
writeln(
On Friday, 2 April 2021 at 04:38:37 UTC, mw wrote:
On Friday, 2 April 2021 at 04:36:01 UTC, rikki cattermole wrote:
I don't get it, what do you mean by the assertion:
assert(t[9] == '\0');
t == "head-abc-tail"
Just tried this:
https://run.dlang.io/is/SFU5p4
```
import std;
import std.conv
On 02/04/2021 5:38 PM, mw wrote:
On Friday, 2 April 2021 at 04:36:01 UTC, rikki cattermole wrote:
On 02/04/2021 5:32 PM, mw wrote:
---
import std;
import std.conv : text;
void main()
{
char[6] s;
s = "abc";
writeln(s, s.length); // abc6, ok it's the static array's length
str
On Friday, 2 April 2021 at 04:36:01 UTC, rikki cattermole wrote:
On 02/04/2021 5:32 PM, mw wrote:
---
import std;
import std.conv : text;
void main()
{
char[6] s;
s = "abc";
writeln(s, s.length); // abc6, ok it's the static array's
length
string t = text("head-", s, "-tail"
On 02/04/2021 5:32 PM, mw wrote:
---
import std;
import std.conv : text;
void main()
{
char[6] s;
s = "abc";
writeln(s, s.length); // abc6, ok it's the static array's length
string t = text("head-", s, "-tail");
writeln(t, t.length); // head-abc-tail16, why?
assert(t[9]
https://run.dlang.io/is/B4jcno
---
import std;
import std.conv : text;
void main()
{
char[6] s;
s = "abc";
writeln(s, s.length); // abc6, ok it's the static array's
length
string t = text("head-", s, "-tail");
writeln(t, t.length); // head-abc-tail16, why?
}
---
Why th
21 matches
Mail list logo