authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-19 01:54:03 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-19 01:54:03 -08:00
log0072865f1e40ae053ab43589bfc27735ce84cf84
treef27da67c0d16c54e1aea9fbb95c2fbc330073711
parentba472f055e4e641958202b0229ef52a8c5193d8b

add some doc comments


2 files changed, 7 insertions(+), 0 deletions(-)

idna.zig+4
...@@ -8,6 +8,7 @@ pub const @"2008" = @import("./2008.zig");...@@ -8,6 +8,7 @@ pub const @"2008" = @import("./2008.zig");
88
9pub const table = @import("./table.zig");9pub const table = @import("./table.zig");
1010
11// https://unicode.org/reports/tr46/#ToASCII
11pub fn ToASCII(12pub fn ToASCII(
12 allocator: std.mem.Allocator,13 allocator: std.mem.Allocator,
13 domain_name: []const u8,14 domain_name: []const u8,
...@@ -44,6 +45,7 @@ pub fn ToASCII(...@@ -44,6 +45,7 @@ pub fn ToASCII(
44 return map.toOwnedSlice();45 return map.toOwnedSlice();
45}46}
4647
48// https://unicode.org/reports/tr46/#ToUnicode
47pub fn ToUnicode(49pub fn ToUnicode(
48 allocator: std.mem.Allocator,50 allocator: std.mem.Allocator,
49 domain_name: []const u8,51 domain_name: []const u8,
...@@ -60,6 +62,7 @@ pub fn ToUnicode(...@@ -60,6 +62,7 @@ pub fn ToUnicode(
60 return map.toOwnedSlice();62 return map.toOwnedSlice();
61}63}
6264
65// https://unicode.org/reports/tr46/#Processing
63fn Processing(66fn Processing(
64 map: *extras.ManyArrayList(u8),67 map: *extras.ManyArrayList(u8),
65 domain_name: []const u8,68 domain_name: []const u8,
...@@ -166,6 +169,7 @@ fn isNFC(map: *const extras.ManyArrayList(u8)) bool {...@@ -166,6 +169,7 @@ fn isNFC(map: *const extras.ManyArrayList(u8)) bool {
166 return false;169 return false;
167}170}
168171
172// https://unicode.org/reports/tr46/#Validity_Criteria
169fn Validity_Criteria(173fn Validity_Criteria(
170 label: []const u8,174 label: []const u8,
171 CheckHyphens: bool,175 CheckHyphens: bool,
normalization.zig+3
...@@ -41,6 +41,7 @@ pub fn ToNFKC(map: *extras.ManyArrayList(u8)) !void {...@@ -41,6 +41,7 @@ pub fn ToNFKC(map: *extras.ManyArrayList(u8)) !void {
41 try CanonicalComposition(map);41 try CanonicalComposition(map);
42}42}
4343
44// https://www.unicode.org/versions/latest/core-spec/chapter-3/#G733
44fn Decomposition(map: *extras.ManyArrayList(u8), kind: enum { canonical, compatibility }) !void {45fn Decomposition(map: *extras.ManyArrayList(u8), kind: enum { canonical, compatibility }) !void {
45 // fully decompose all codepoints in the string46 // fully decompose all codepoints in the string
46 var n: usize = 0;47 var n: usize = 0;
...@@ -101,6 +102,7 @@ fn Decomposition(map: *extras.ManyArrayList(u8), kind: enum { canonical, compati...@@ -101,6 +102,7 @@ fn Decomposition(map: *extras.ManyArrayList(u8), kind: enum { canonical, compati
101 }102 }
102}103}
103104
105// https://www.unicode.org/versions/latest/core-spec/chapter-3/#G50628
104fn CanonicalComposition(map: *extras.ManyArrayList(u8)) !void {106fn CanonicalComposition(map: *extras.ManyArrayList(u8)) !void {
105 if (map.lengths.items.len < 2) {107 if (map.lengths.items.len < 2) {
106 return;108 return;
...@@ -157,6 +159,7 @@ fn CanonicalComposition(map: *extras.ManyArrayList(u8)) !void {...@@ -157,6 +159,7 @@ fn CanonicalComposition(map: *extras.ManyArrayList(u8)) !void {
157 break;159 break;
158 }160 }
159 }161 }
162 // https://www.unicode.org/versions/latest/core-spec/chapter-3/#G56669
160 i = 0;163 i = 0;
161 while (i < map.lengths.items.len) : (i += 1) {164 while (i < map.lengths.items.len) : (i += 1) {
162 const sll = map.items(i);165 const sll = map.items(i);