Skip to content

Strings broken for multibytes #294

Description

@danon

Commit 017bbe6 probably broke multi-byte safety, because this test now fails (test not in ouzo, I just wrote it)

/**
 * @test
 */
public function shouldNotStartWithMalformedUnicode()
{
    // given
    $subject = '';
    $infix = \chr(226);

    // when
    $startsWith = Strings::startsWith($subject, $infix); // returns true

    // then
    $this->assertFalse($startsWith);
}

str_starts_with() is not mb-safe. Previous implementation would make this test pass. Maybe revert?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions