Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tests/Test_Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ function test_decolorize() {
}

function test_strwidth() {
$this->markTestSkipped('Unknown failure');
// Save.
$test_strwidth = getenv( 'PHP_CLI_TOOLS_TEST_STRWIDTH' );
if ( function_exists( 'mb_detect_order' ) ) {
Expand Down Expand Up @@ -446,12 +445,14 @@ function test_strwidth() {
}

// Nepali जस्ट ट॓स्ट गर्दै - 1st word: 3 spacing + 1 combining, 2nd word: 3 spacing + 2 combining, 3rd word: 3 spacing + 2 combining = 9 spacing chars + 2 spaces = 11 chars.
// Note: ICU's grapheme_strlen() treats Devanagari conjuncts (consonant + virama + consonant) as single graphemes.
// Modern ICU versions (54.1+) return 8 for this string, while PCRE \X returns 11.
$str = "\xe0\xa4\x9c\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\x9f \xe0\xa4\x9f\xe0\xa5\x93\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\x9f \xe0\xa4\x97\xe0\xa4\xb0\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x88";

putenv( 'PHP_CLI_TOOLS_TEST_STRWIDTH' );

if ( \cli\can_use_icu() ) {
$this->assertSame( 11, \cli\strwidth( $str ) ); // Tests grapheme_strlen().
$this->assertSame( 8, \cli\strwidth( $str ) ); // Tests grapheme_strlen() - ICU treats conjuncts as single graphemes.
putenv( 'PHP_CLI_TOOLS_TEST_STRWIDTH=2' ); // Test preg_split( '/\X/u' ).
$this->assertSame( 11, \cli\strwidth( $str ) );
} else {
Expand Down
Loading