refactor: add unicode.is_lowercase
This commit is contained in:
parent
047409cd29
commit
abee93d366
1 changed files with 5 additions and 1 deletions
|
|
@ -135,7 +135,7 @@ fn utf8_transform(comptime field: uucode.FieldEnum, allocator: std.mem.Allocator
|
||||||
return result.toOwnedSlice();
|
return result.toOwnedSlice();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn utf8_predicate(comptime field: uucode.FieldEnum, text: []const u8) TransformError!bool {
|
fn utf8_predicate(comptime field: uucode.FieldEnum, text: []const u8) error{InvalidUtf8}!bool {
|
||||||
const view: std.unicode.Utf8View = try .init(text);
|
const view: std.unicode.Utf8View = try .init(text);
|
||||||
var it = view.iterator();
|
var it = view.iterator();
|
||||||
while (it.nextCodepoint()) |cp| {
|
while (it.nextCodepoint()) |cp| {
|
||||||
|
|
@ -177,5 +177,9 @@ pub fn switch_case(allocator: std.mem.Allocator, text: []const u8) TransformErro
|
||||||
to_lower(allocator, text);
|
to_lower(allocator, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_lowercase(text: []const u8) error{InvalidUtf8}!bool {
|
||||||
|
return try utf8_predicate(.is_lowercase, text);
|
||||||
|
}
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const uucode = @import("vaxis").uucode;
|
const uucode = @import("vaxis").uucode;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue