| ... | @@ -164,7 +164,6 @@ pub fn utf8ValidCodepoint(value: u21) bool { | ... | @@ -164,7 +164,6 @@ pub fn utf8ValidCodepoint(value: u21) bool { |
| 164 | | 164 | |
| 165 | /// Returns the length of a supplied UTF-8 string literal in terms of unicode | 165 | /// Returns the length of a supplied UTF-8 string literal in terms of unicode |
| 166 | /// codepoints. | 166 | /// codepoints. |
| 167 | /// Asserts that the data is valid UTF-8. | | |
| 168 | pub fn utf8CountCodepoints(s: []const u8) !usize { | 167 | pub fn utf8CountCodepoints(s: []const u8) !usize { |
| 169 | var len: usize = 0; | 168 | var len: usize = 0; |
| 170 | | 169 | |
| ... | @@ -351,7 +350,6 @@ fn testUtf16CountCodepoints() !void { | ... | @@ -351,7 +350,6 @@ fn testUtf16CountCodepoints() !void { |
| 351 | @as(usize, 5), | 350 | @as(usize, 5), |
| 352 | try utf16CountCodepoints(utf8ToUtf16LeStringLiteral("こんにちは")), | 351 | try utf16CountCodepoints(utf8ToUtf16LeStringLiteral("こんにちは")), |
| 353 | ); | 352 | ); |
| 354 | // testing.expectError(error.Utf8EncodesSurrogateHalf, utf8CountCodepoints("\xED\xA0\x80")); | | |
| 355 | } | 353 | } |
| 356 | | 354 | |
| 357 | test "utf16 count codepoints" { | 355 | test "utf16 count codepoints" { |
| ... | @@ -820,7 +818,6 @@ fn testCalcUtf16LeLen() !void { | ... | @@ -820,7 +818,6 @@ fn testCalcUtf16LeLen() !void { |
| 820 | try testing.expectEqual(@as(usize, 10), try calcUtf16LeLen("abcdefghij")); | 818 | try testing.expectEqual(@as(usize, 10), try calcUtf16LeLen("abcdefghij")); |
| 821 | try testing.expectEqual(@as(usize, 10), try calcUtf16LeLen("äåéëþüúíóö")); | 819 | try testing.expectEqual(@as(usize, 10), try calcUtf16LeLen("äåéëþüúíóö")); |
| 822 | try testing.expectEqual(@as(usize, 5), try calcUtf16LeLen("こんにちは")); | 820 | try testing.expectEqual(@as(usize, 5), try calcUtf16LeLen("こんにちは")); |
| 823 | // testing.expectError(error.Utf8EncodesSurrogateHalf, utf8CountCodepoints("\xED\xA0\x80")); | | |
| 824 | } | 821 | } |
| 825 | | 822 | |
| 826 | test "calculate utf16 string length of given utf8 string in u16" { | 823 | test "calculate utf16 string length of given utf8 string in u16" { |