Skip to content

Stdlib: grapheme_strsplit() — ICU grapheme cluster split missing (ext/intl/grapheme) #6246

Description

@PurHur

Category

stdlibimplementation-ready (VM landed; JIT + compliance remain)

Status (2026-06-18 audit)

grapheme_str_split() is registered on VM (ext/intl/grapheme_str_split.php, VmGrapheme). function_exists('grapheme_str_split')true on bin/vm.php.

Still open for this issue:

Problem

grapheme_str_split() splits on grapheme cluster boundaries (combining characters stay attached). Apps expect it alongside grapheme_strlen() / grapheme_substr() (#3352).

php-src reference

Repro — existence (VM green)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_export(function_exists(\"grapheme_str_split\")); echo \"\\n\";"'
# bool(true)

Repro — behavior (compare Zend + VM)

Use committed maintainer script test/repro-maintainer/grapheme_str_split_missing.php:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/grapheme_str_split_missing.php
php bin/vm.php test/repro-maintainer/grapheme_str_split_missing.php'

Expected Zend + VM (php-src-strict):

Case Output shape
"e\xCC\x81" (one grapheme) array(1) { [0]=> string(3) … }
'abc' three single-char graphemes
'abcdef', 2 chunks of 2 graphemes

Repro — JIT gap

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/jit.php test/repro-maintainer/grapheme_str_split_missing.php 2>&1 | head -5'
# deferred / not implemented — must not segfault

Scope (this repo)

PHP-in-PHP: ICU/cluster logic in ext/intl/ PHP, not runtime/*.c.

Done when

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter grapheme_str_split'
./script/ci-fast.sh --filter grapheme_str_split

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions