Skip to content

Commit d798e3c

Browse files
authored
builtin: fix typo in range in utf8_str_visible_length(), add test (#25715)
1 parent 4c22789 commit d798e3c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

vlib/builtin/utf8.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub fn utf8_str_visible_length(s string) int {
181181
// CJK Unified Ideographs Extension B-G
182182
// TODO: remove this workaround for v2's parser
183183
// vfmt off
184-
if (r >= 0x0f9f8880 && r <= 0xf09f8a8f) ||
184+
if (r >= 0xf09f8880 && r <= 0xf09f8a8f) ||
185185
(r >= 0xf09f8c80 && r <= 0xf09f9c90) ||
186186
(r >= 0xf09fa490 && r <= 0xf09fa7af) ||
187187
(r >= 0xf0a08080 && r <= 0xf180807f) {

vlib/builtin/utf8_test.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,7 @@ fn test_wide_to_ansi() {
9797
fn test_string_to_ansi_not_null_terminated() {
9898
assert string_to_ansi_not_null_terminated('abc') == [u8(97), 98, 99]
9999
}
100+
101+
fn test_utf8_str_visible_length() {
102+
assert utf8_str_visible_length('𝐀𝐁𝐂') == 3
103+
}

0 commit comments

Comments
 (0)