On 9/22/22 14:31, Salih Dincer wrote:
> string splitz(string s)
> {
>import std.string : indexOf;
>auto seekPos = s.indexOf('\0');
>return seekPos > 0 ? s[0..seekPos] : s;
> }
If you have multiple '\0' chars that you will continue looking for, how
about the following?
import std;
On Thursday, 22 September 2022 at 20:53:28 UTC, Salih Dincer
wrote:
```d
string splitz(string s)
{
import std.string : indexOf;
size_t seekPos = s.indexOf('\0');
return s[0..seekPos];
}
```
I ignored the possibility of not finding '\0'. I'm fixing it now:
```d
string splitz(string s)
{
On Thursday, 22 September 2022 at 15:22:06 UTC, Ali Çehreli wrote:
On 9/22/22 08:19, Ali Çehreli wrote:
> ```d
> string noZeroes(string s)
> {
> return s.byCodeUnit.filter!(c => c != '\0');
> }
> ```
That won't compile; the return type must be 'auto'.
Ali
Thank you for all the valuable
On 9/22/22 08:19, Ali Çehreli wrote:
> string noZeroes(string s)
> {
> return s.byCodeUnit.filter!(c => c != '\0');
> }
That won't compile; the return type must be 'auto'.
Ali
On 9/22/22 03:53, Salih Dincer wrote:
> Is there a more accurate way to delete the '\0' characters at the end of
> the string? I tried functions in this module:
> https://dlang.org/phobos/std_string.html
Just to remind, the following are always related as well because strings
are arrays, which
On Thursday, 22 September 2022 at 10:53:32 UTC, Salih Dincer
wrote:
Is there a more accurate way to delete the '\0' characters at
the end of the string? I tried functions in this module:
https://dlang.org/phobos/std_string.html
```d
auto foo(string s)
{
string r;
foreach(c; s)
{
On Thursday, 22 September 2022 at 13:29:43 UTC, user1234 wrote:
Two remarks:
1. The zero implicitly added to literals is not part of the
string. for example s[$-1] will not give 0 unless you added it
explictly to a literal
2. you code remove all the 0, not the one at the end. As it
still
On Thursday, 22 September 2022 at 10:53:32 UTC, Salih Dincer
wrote:
Is there a more accurate way to delete the '\0' characters at
the end of the string? I tried functions in this module:
https://dlang.org/phobos/std_string.html
```d
auto foo(string s)
{
string r;
foreach(c; s)
{
On 22.09.22 13:14, ag0aep6g wrote:
On 22.09.22 12:53, Salih Dincer wrote:
[...]
```d
auto foo(string s)
{
string r;
foreach(c; s)
{
if(c > 0)
{
r ~= c;
}
}
return r;
}
```
[...]
Here's a snippet that's a bit shorter than yours and doesn't copy the data:
Hi guys!
What's the best/preferred library to use for serial communication
(RS)?
Thanks
On 22.09.22 12:53, Salih Dincer wrote:
Is there a more accurate way to delete the '\0' characters at the end of
the string? I tried functions in this module:
https://dlang.org/phobos/std_string.html
```d
auto foo(string s)
{
string r;
foreach(c; s)
{
if(c > 0)
{
r ~=
Is there a more accurate way to delete the '\0' characters at the
end of the string? I tried functions in this module:
https://dlang.org/phobos/std_string.html
```d
auto foo(string s)
{
string r;
foreach(c; s)
{
if(c > 0)
{
r ~= c;
}
}
return r;
}
```
SDB@79
It's possible to remove the "@" annotation & use the default
names of functions for the vibe framework,
E.g,
```
final class WebChat
{
// GET /
void get()
{
render!("index.dt", names);
}
void getEdit(string myid)
{
int id = myid.to!int;
string
13 matches
Mail list logo