Project

General

Profile

Actions

Bug #17467

closed

What makes strip() and lstrip() not stripping \u0000 from beginning of the string?

Added by SouravGoswami (Sourav Goswami) over 3 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
[ruby-core:101676]

Description

Both strip(), and rstrip() will delete \u0000 from the end of a string. But I have a string that has "\u0000hello\u0000".

Output from strip, lstrip and rstrip:

"\u0000hello\u0000".strip # => "\u0000hello"
"\u0000hello\u0000".lstrip # => "\u0000hello\u0000"
"\u0000hello\u0000".rstrip # => "\u0000hello"

Same goes for \x00 as well.

While it's quite ridiculous to have NULL at the beginning of the string, but what makes it not strip? Is that slow or is that because it's never used?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0