Skip to content

ext/mbstring: Update to Unicode 15.1 #14680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ PHP NEWS
- MBString:
. Added mb_trim, mb_ltrim and mb_rtrim. (Yuya Hamada)
. Added mb_ucfirst and mb_lcfirst. (Yuya Hamada)
. Updated Unicode data tables to Unicode 15.1. (Ayesh Karunaratne)

- MySQLnd:
. Fixed bug GH-13440 (PDO quote bottleneck). (nielsdos)
Expand Down
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,9 @@ PHP 8.4 UPGRADE NOTES
$domain name is empty or too long, and if $variant is not
INTL_IDNA_VARIANT_UTS46.

- MBString:
. Unicode data tables have been updated to Unicode 15.1.

- OpenSSL:
. The OpenSSL extension now requires at least OpenSSL 1.1.1.

Expand Down
25 changes: 12 additions & 13 deletions ext/mbstring/libmbfl/mbfl/eaw_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ static const struct {
{ 0x2e80, 0x2e99 },
{ 0x2e9b, 0x2ef3 },
{ 0x2f00, 0x2fd5 },
{ 0x2ff0, 0x2ffb },
{ 0x3000, 0x303e },
{ 0x2ff0, 0x303e },
{ 0x3041, 0x3096 },
{ 0x3099, 0x30ff },
{ 0x3105, 0x312f },
{ 0x3131, 0x318e },
{ 0x3190, 0x31e3 },
{ 0x31f0, 0x321e },
{ 0x31ef, 0x321e },
{ 0x3220, 0x3247 },
{ 0x3250, 0x4dbf },
{ 0x4e00, 0xa48c },
Expand All @@ -88,7 +87,9 @@ static const struct {
{ 0x1aff5, 0x1affb },
{ 0x1affd, 0x1affe },
{ 0x1b000, 0x1b122 },
{ 0x1b132, 0x1b132 },
{ 0x1b150, 0x1b152 },
{ 0x1b155, 0x1b155 },
{ 0x1b164, 0x1b167 },
{ 0x1b170, 0x1b2fb },
{ 0x1f004, 0x1f004 },
Expand Down Expand Up @@ -122,23 +123,21 @@ static const struct {
{ 0x1f6cc, 0x1f6cc },
{ 0x1f6d0, 0x1f6d2 },
{ 0x1f6d5, 0x1f6d7 },
{ 0x1f6dd, 0x1f6df },
{ 0x1f6dc, 0x1f6df },
{ 0x1f6eb, 0x1f6ec },
{ 0x1f6f4, 0x1f6fc },
{ 0x1f7e0, 0x1f7eb },
{ 0x1f7f0, 0x1f7f0 },
{ 0x1f90c, 0x1f93a },
{ 0x1f93c, 0x1f945 },
{ 0x1f947, 0x1f9ff },
{ 0x1fa70, 0x1fa74 },
{ 0x1fa78, 0x1fa7c },
{ 0x1fa80, 0x1fa86 },
{ 0x1fa90, 0x1faac },
{ 0x1fab0, 0x1faba },
{ 0x1fac0, 0x1fac5 },
{ 0x1fad0, 0x1fad9 },
{ 0x1fae0, 0x1fae7 },
{ 0x1faf0, 0x1faf6 },
{ 0x1fa70, 0x1fa7c },
{ 0x1fa80, 0x1fa88 },
{ 0x1fa90, 0x1fabd },
{ 0x1fabf, 0x1fac5 },
{ 0x1face, 0x1fadb },
{ 0x1fae0, 0x1fae8 },
{ 0x1faf0, 0x1faf8 },
{ 0x20000, 0x2fffd },
{ 0x30000, 0x3fffd },
};
28 changes: 28 additions & 0 deletions ext/mbstring/tests/unicode_versions.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
mbstring Unicode Data tests
--EXTENSIONS--
mbstring
--FILE--
<?php

print "ASCII (PHP): " . mb_strwidth('PHP', 'UTF-8') . "\n";

print "Vietnamese (Xin chào): " . mb_strwidth('Xin chào', 'UTF-8') . "\n";

print "Traditional Chinese (你好): " . mb_strwidth('你好', 'UTF-8') . "\n";

print "Sinhalese (අයේෂ්): " . mb_strwidth('අයේෂ්', 'UTF-8') . "\n";

print "Emoji (\u{1F418}): " . mb_strwidth("\u{1F418}", 'UTF-8') . "\n";

// New in Unicode 15.0, width=2
print "Emoji (\u{1F6DC}): " . mb_strwidth("\u{1F6DC}", 'UTF-8') . "\n";

?>
--EXPECT--
ASCII (PHP): 3
Vietnamese (Xin chào): 8
Traditional Chinese (你好): 4
Sinhalese (අයේෂ්): 5
Emoji (🐘): 2
Emoji (🛜): 2
16 changes: 12 additions & 4 deletions ext/mbstring/ucgendat/ucgendat.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,22 @@ function parseSpecialCasing(UnicodeData $data, string $input) : void {

function parseDerivedCoreProperties(UnicodeData $data, string $input) : void {
foreach (parseDataFile($input) as $fields) {
if (count($fields) != 2) {
throw new Exception("Line does not contain 2 fields");
$fieldCount = count($fields);
if ($fieldCount != 2 && $fieldCount !== 3) {
throw new Exception("Line does not contain 2 or 3 fields");
}

$property = $fields[1];
if ($property != 'Cased' && $property != 'Case_Ignorable') {
$usedProperties = ['Cased', 'Case_Ignorable'];
if (isset($fields[2]) && in_array($fields[2], $usedProperties, true)) {
$property = $fields[2];
}
elseif (!in_array($fields[1], $usedProperties, true)) {
continue;
}
else{
$property = $fields[1];
}


$range = explode('..', $fields[0]);
if (count($range) == 2) {
Expand Down
Loading
Loading