summaryrefslogtreecommitdiff
path: root/clap/codepoint_counting_writer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'clap/codepoint_counting_writer.zig')
-rw-r--r--clap/codepoint_counting_writer.zig7
1 files changed, 3 insertions, 4 deletions
diff --git a/clap/codepoint_counting_writer.zig b/clap/codepoint_counting_writer.zig
index e6b9d1c..c445c90 100644
--- a/clap/codepoint_counting_writer.zig
+++ b/clap/codepoint_counting_writer.zig
@@ -1,7 +1,3 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const native_endian = builtin.cpu.arch.endian();
4
5/// A Writer that counts how many codepoints has been written to it. 1/// A Writer that counts how many codepoints has been written to it.
6/// Expects valid UTF-8 input, and does not validate the input. 2/// Expects valid UTF-8 input, and does not validate the input.
7pub fn CodepointCountingWriter(comptime WriterType: type) type { 3pub fn CodepointCountingWriter(comptime WriterType: type) type {
@@ -34,6 +30,7 @@ pub fn CodepointCountingWriter(comptime WriterType: type) type {
34// the number of codepoints up to that point. 30// the number of codepoints up to that point.
35// Does not validate UTF-8 beyond checking the start byte. 31// Does not validate UTF-8 beyond checking the start byte.
36fn utf8CountCodepointsAllowTruncate(s: []const u8) !struct { bytes: usize, codepoints: usize } { 32fn utf8CountCodepointsAllowTruncate(s: []const u8) !struct { bytes: usize, codepoints: usize } {
33 const native_endian = @import("builtin").cpu.arch.endian();
37 var len: usize = 0; 34 var len: usize = 0;
38 35
39 const N = @sizeOf(usize); 36 const N = @sizeOf(usize);
@@ -100,3 +97,5 @@ test "handles partial UTF-8 writes" {
100 97
101 try testing.expectEqualSlices(u8, utf8_text, fbs.getWritten()); 98 try testing.expectEqualSlices(u8, utf8_text, fbs.getWritten());
102} 99}
100
101const std = @import("std");