php / php/php-src

Expose a function to check whether a string is valid UTF-8

Open
#20,984 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Checking whether a string is valid UTF-8 is a common need, as many projects require UTF-8 encoding (to be able to use the u modifier in regex for instance, among other use cases).

As zend_string already has internal optimizations to remember that a string is valid UTF-8, implementing such function in core would provide several benefits over a userland implementation (it can both read the flag for a fast-path answer and set the flag at the end of the slow path to remember the validity for next usages of the string).

This could be implemented as a function is_valid_utf8(string $string): bool function

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating zend_string and the existing UTF-8 validity tracking or validation logic in the PHP core. The work is done when an is_valid_utf8(string $string): bool function is exposed and can use the remembered validity while establishing it for subsequent calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.