| author | |
| committer | |
| log | 0072865f1e40ae053ab43589bfc27735ce84cf84 |
| tree | f27da67c0d16c54e1aea9fbb95c2fbc330073711 |
| parent | ba472f055e4e641958202b0229ef52a8c5193d8b |
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"); |
| 8 | 8 | ||
| 9 | pub const table = @import("./table.zig"); | 9 | pub const table = @import("./table.zig"); |
| 10 | 10 | ||
| 11 | // https://unicode.org/reports/tr46/#ToASCII | ||
| 11 | pub fn ToASCII( | 12 | pub 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 | } |
| 46 | 47 | ||
| 48 | // https://unicode.org/reports/tr46/#ToUnicode | ||
| 47 | pub fn ToUnicode( | 49 | pub 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 | } |
| 62 | 64 | ||
| 65 | // https://unicode.org/reports/tr46/#Processing | ||
| 63 | fn Processing( | 66 | fn 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 | } |
| 168 | 171 | ||
| 172 | // https://unicode.org/reports/tr46/#Validity_Criteria | ||
| 169 | fn Validity_Criteria( | 173 | fn 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 | } |
| 43 | 43 | ||
| 44 | // https://www.unicode.org/versions/latest/core-spec/chapter-3/#G733 | ||
| 44 | fn Decomposition(map: *extras.ManyArrayList(u8), kind: enum { canonical, compatibility }) !void { | 45 | fn Decomposition(map: *extras.ManyArrayList(u8), kind: enum { canonical, compatibility }) !void { |
| 45 | // fully decompose all codepoints in the string | 46 | // 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 | } |
| 103 | 104 | ||
| 105 | // https://www.unicode.org/versions/latest/core-spec/chapter-3/#G50628 | ||
| 104 | fn CanonicalComposition(map: *extras.ManyArrayList(u8)) !void { | 106 | fn 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); |