summaryrefslogtreecommitdiff
path: root/src/code_point.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/code_point.zig')
-rw-r--r--src/code_point.zig13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/code_point.zig b/src/code_point.zig
index 7a638af..5f6c61c 100644
--- a/src/code_point.zig
+++ b/src/code_point.zig
@@ -30,13 +30,8 @@ pub const CodePoint = struct {
30/// This function is deprecated and will be removed in a later release. 30/// This function is deprecated and will be removed in a later release.
31/// Use `decodeAtIndex` or `decodeAtCursor`. 31/// Use `decodeAtIndex` or `decodeAtCursor`.
32pub fn decode(bytes: []const u8, offset: uoffset) ?CodePoint { 32pub fn decode(bytes: []const u8, offset: uoffset) ?CodePoint {
33 var off: uoffset = 0; 33 _ = .{ bytes, offset };
34 var maybe_code = decodeAtCursor(bytes, &off); 34 @compileError("decode has been removed, use `decodeAtIndex`.");
35 if (maybe_code) |*code| {
36 code.offset = offset;
37 return code.*;
38 }
39 return null;
40} 35}
41 36
42/// Return the codepoint at `index`, even if `index` is in the middle 37/// Return the codepoint at `index`, even if `index` is in the middle
@@ -292,7 +287,7 @@ pub const ReverseIterator = struct {
292 else 287 else
293 iter.i = null; 288 iter.i = null;
294 289
295 return decode(iter.bytes[i_prev..], i_prev); 290 return decodeAtIndex(iter.bytes, i_prev);
296 } 291 }
297 292
298 pub fn peek(iter: *ReverseIterator) ?CodePoint { 293 pub fn peek(iter: *ReverseIterator) ?CodePoint {
@@ -319,7 +314,7 @@ inline fn followbyte(b: u8) bool {
319 314
320test "decode" { 315test "decode" {
321 const bytes = "🌩️"; 316 const bytes = "🌩️";
322 const res = decode(bytes, 0); 317 const res = decodeAtIndex(bytes, 0);
323 318
324 if (res) |cp| { 319 if (res) |cp| {
325 try std.testing.expectEqual(@as(u21, 0x1F329), cp.code); 320 try std.testing.expectEqual(@as(u21, 0x1F329), cp.code);