Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unicode.splitWhitespace() and strutils.splitWhitespace() have different results for ASCII string #23619

Open
simonkrauter opened this issue May 16, 2024 · 0 comments

Comments

@simonkrauter
Copy link
Contributor

simonkrauter commented May 16, 2024

Description

unicode.splitWhitespace() returns empty strings, but strutils.splitWhitespace() not.

Test program:

import std / strutils
import std / unicode

let s = "  foo \t bar  baz  "
echo strutils.splitWhitespace(s)
echo unicode.splitWhitespace(s)

Nim Version

Nim Compiler Version 2.0.4 [Linux: amd64]
Compiled at 2024-03-28
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: b47747d
active boot switches: -d:release

Current Output

@["foo", "bar", "baz"]
@["", "", "foo", "", "", "bar", "", "baz", "", ""]

Expected Output

Two times the same output.

Possible Solution

To me it looks like unicode.splitWhitespace() should be adapted to the behaviour of strutils.splitWhitespace(), because the behavior of strutils.splitWhitespace() is documented (https://github.com/nim-lang/Nim/blob/version-2-0/lib/pure/strutils.nim#L698).

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant