src/site/php unicode-tables.php

Functions

cfw_mb_unicode_data()

cfw_mb_unicode_data() : array<string,mixed>

The table, or an empty one.

An empty table is not a failure mode, it is the polyfill unchanged: every lookup misses, cfw_mb_patch returns its input and both generated patterns come back null, so a site with no driver pack answers exactly what it answered before the table existed.

Returns

array —

The case, width and lead-byte tables keyed by name.

cfw_mb_patch()

cfw_mb_patch(string  $s, string  $which) : string

Pre-maps the codepoints the polyfill would answer wrongly, so its own pass then sees a character it already agrees with.

Pre and not post: the polyfill's wrong answer is ambiguous -- three characters share one stale uppercase -- so a table keyed on its OUTPUT cannot recover the input it came from. strpbrk first, because a string carrying none of the keys' lead bytes cannot need the strtr.

Parameters

string $s

Well-formed UTF-8.

string $which

lower or upper.

Returns

string —

cfw_mb_title_char()

cfw_mb_title_char(string  $ch) : ?string

The titlecase of a word-initial character, or null where the polyfill is already right.

Parameters

string $ch

One character.

Returns

?string —

cfw_mb_fold_safe()

cfw_mb_fold_safe(string  $s) : string

A length-PRESERVING fold, which is what the case-insensitive searches need.

The polyfill lowercases first, and one codepoint lowercases to two (U+0130 gives i plus a combining dot), so every index past it shifts and mb_stripos answers an offset into a string the caller never passed.

Parameters

string $s

Well-formed UTF-8.

Returns

string —

cfw_mb_wide_regexp()

cfw_mb_wide_regexp() : ?string

East asian width from mbstring's table; null when the pack is absent.

Returns

?string —

cfw_mb_width()

cfw_mb_width(string  $s, string  $re) : int

Parameters

string $s

Well-formed UTF-8.

string $re

The pattern from cfw_mb_wide_regexp().

Returns

int —

cfw_mb_title_extra()

cfw_mb_title_extra() : string

The class body spliced into the word pattern, empty when the pack is absent.

Returns

string —