Skip to content

Fix mb_strlen UTF-8 character counting (closes #158)#391

Merged
PurHur merged 1 commit into
masterfrom
issue-158-mb-strlen-utf8
May 20, 2026
Merged

Fix mb_strlen UTF-8 character counting (closes #158)#391
PurHur merged 1 commit into
masterfrom
issue-158-mb-strlen-utf8

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented May 20, 2026

Summary

  • mb_strlen() now returns UTF-8 codepoint counts (not byte length) for default/UTF-8 encoding in VM and JIT
  • VM uses host mb_strlen() when mbstring is available, with VmString::utf8CharLength() fallback
  • JIT/AOT call new __compiler_utf8_strlen runtime helper; compile-time string literals fold at build time
  • Added VM compliance PHPT and updated JIT PHPT for é and hello

Test plan

  • vendor/bin/phpunit --filter mb_strlen test/ in php-compiler:22.04-dev (2 tests OK)
  • Harness: tar-pipe into Docker when bind-mount is empty

Closes #158

Made with Cursor

Use host mb_strlen when available, VmString::utf8CharLength fallback, and
__compiler_utf8_strlen for JIT/AOT. Add compliance PHPT for é and hello.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 56f40b0 into master May 20, 2026
@PurHur PurHur deleted the issue-158-mb-strlen-utf8 branch May 20, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: mb_strlen and UTF-8 byte-safe string metrics

1 participant