Zig NEWS

Discussion on: New way to split and iterate over strings

Collapse
 
jpl profile image
Jean-Pierre • Edited

linux zig 0.10.0 error: root struct of file 'mem' has no member named 'window'
var it = std.mem.window(u8, buffer, 1, 1);

const buffer = "àéç";
var it = std.mem.window(u8, buffer, 1, 1);
while (it.next()) |slice| {
std.debug.print("value:{any}",.{slice});
}

Only works with the master version,
on the other hand does not support UTF8
only american ascii 128
too bad, because we are not far from Rune de nim-lang

Collapse
 
lisael profile image
Lisael

It's a low level memory operation. It's just a sliding window along an array in memory. It's presented in examples as a string tool (as [_]const u8 are the easiest array to create in a small example snippet), but it's really not. Low level memory operations are useless when dealing with real world strings (except that they may be blocks to build higher-level ops).

What you want is github.com/JakubSzark/zig-string that does exactly that.

Collapse
 
jpl profile image
Jean-Pierre

zig-string isn't bad, but it's missing some stuff.