fixes #19846; std/unicode.strip trailing big chars (#25274)

fixes #19846

(cherry picked from commit 2679b3221c)
This commit is contained in:
lit
2025-11-11 19:01:07 +08:00
committed by narimiran
parent c75c85cbf8
commit 9346b138e1
2 changed files with 31 additions and 10 deletions

View File

@@ -194,6 +194,23 @@ block stripTests:
doAssert(strip("×text×", leading = false, runes = ["×".asRune]) == "×text")
doAssert(strip("×text×", trailing = false, runes = ["×".asRune]) == "text×")
doAssert(strip("\u2000") == "")
doAssert(strip("a\u2000") == "a")
# bug #19846
block:
# check against unicode whose utf8 byteLen > 2
doAssert(strip("‟„”“‗•STR•‗“”„‟", runes = "•‗‘’‚‛“”„‟".toRunes) == "STR")
let chi = "abc\u8377\u9020"
doAssert(strip(chi, leading = false, runes = ["\u9020".asRune]) == "abc\u8377")
doAssert(strip(chi) == chi) # the last byte of s is \x0a, which is in unicodeSpace
let
grinning_face = "\u{1f600}"
thinking_face = "\u{1f914}"
doAssert(strip(grinning_face & thinking_face & thinking_face,
runes = thinking_face.toRunes) == grinning_face)
block repeatTests:
doAssert repeat('c'.Rune, 5) == "ccccc"
doAssert repeat("×".asRune, 5) == "×××××"