ouzo icon indicating copy to clipboard operation
ouzo copied to clipboard

`Strings` broken for multibytes

Open danon opened this issue 4 years ago • 0 comments

Commit https://github.com/letsdrink/ouzo/commit/017bbe6754528784bfed76adff50c8b5210e2d9a 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?

danon avatar Sep 20 '21 13:09 danon