Skip to content

Stdlib: mb_convert_encoding / mb_detect_encoding (ext/mbstring parity) #3075

Description

@PurHur

Category

stdlib

Problem

Only mb_strlen() is implemented (ext/types/mb_strlen.php). Web and CLI apps need mb_convert_encoding() and mb_detect_encoding() for charset pipelines (form uploads, legacy ISO-8859-1 sources, UTF-8 normalization).

Both functions are undefined in this compiler today.

php-src reference

Repro (today)

<?php
$iso = "\xE9"; // é in ISO-8859-1
echo mb_convert_encoding($iso, 'UTF-8', 'ISO-8859-1'), "\n";
echo mb_detect_encoding($iso, ['ISO-8859-1', 'UTF-8'], true), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
# Call to undefined function mb_convert_encoding()

./script/docker-exec.sh -- bash -lc 'php repro.php'
# UTF-8 é + ISO-8859-1

Scope (this repo)

Piece Path
Module new ext/mbstring/Module.php or extend ext/types/
VM delegate to host \mb_convert_encoding / \mb_detect_encoding when ext/mbstring loaded; clear error when unavailable
Register ext/standard/Module.php or dedicated mbstring module loader
v1 surface mb_convert_encoding, mb_detect_encoding (+ MB_* encoding name constants subset)
JIT Deferred (VM-first)
Tests test/compliance/cases/stdlib/mb_convert_encoding.phpt, mb_detect_encoding.phpt

Done when

  • Repro output byte-identical to Zend on Docker harness (UTF-8 é + ISO-8859-1)
  • Invalid encoding name → false + warning (Zend parity)
  • Capability matrix rows added via script/capability-matrix.php
  • ./script/ci-fast.sh --filter MbConvert green

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