-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathhello-strings.zig
More file actions
27 lines (24 loc) · 891 Bytes
/
hello-strings.zig
File metadata and controls
27 lines (24 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const std = @import("std");
const debugPrint = std.debug.print;
const stdMem = std.mem; // to compare bytes
pub fn sampleStrings() !void {
debugPrint("=================== STRINGS\n", .{});
const ehlo = "EHLO WORLD";
debugPrint("STRINGS\n", .{});
debugPrint("=> {}\n", .{@TypeOf(ehlo)});
debugPrint("=> {d}\n", .{ehlo.len});
debugPrint("=> {c}\n", .{ehlo[1]});
debugPrint("=> {d}\n", .{ehlo[0]});
debugPrint("=> {}\n", .{ehlo[4] == '\x20'});
debugPrint("=> {d}\n", .{'\u{1f4a9}'});
debugPrint("=> {d}\n", .{'\u{1f4af}'});
debugPrint("=> {d}\n", .{'💯'});
debugPrint("=> 0x{x}\n", .{"\xff"[0]});
debugPrint("=> {u}\n", .{'⚡'});
debugPrint("=> {s} == EHLO\\x20WORLD | {}\n", .{ ehlo, stdMem.eql(u8, ehlo, "EHLO\x20WORLD") });
const multi_ehlo =
\\EHLO
\\WORLD
;
debugPrint("=> {s}\n", .{multi_ehlo});
}