php-src icon indicating copy to clipboard operation
php-src copied to clipboard

Regex pattern modifier u needed with umlaut on Arch, but not Ubuntu, Windows, alpine

Open FlyingHelix opened this issue 4 years ago • 5 comments

Description

The following code:

<?php
    var_dump(preg_match('/^[\p{L}\p{Mn}\W]{8,128}$/', 'gülitgesWort'));
    var_dump(preg_match('/^[\p{L}\p{Mn}\W]{8,128}$/u', 'gülitgesWort'));

Resulted in this output on Windows 10, last used was 21h1 with xampp, Ubuntu different Versions, 20.04, 21.04 and 21.10 and the php:alpine docker image :

int(1)
int(1) 

and this output on Arch Linux, x86_64, Kernel 5.15.13-zen1-1-zen

int(0)
int(1)

on different PHP versions as well, namely 7.4, 8.0.14, 8.0.12 and 8.1 could be a local issue with my arch distro as well, but i used the same locale from a working Ubuntu setup for example as a test.

PHP Version

PHP 8.0.14

Operating System

No response

FlyingHelix avatar Jan 10 '22 17:01 FlyingHelix

I get

int(0)
int(1)

with PHP-8.0 on Windows as well with all supported PHP versions on 3v4l.org (Linux). And that is what would have expected. I wonder what's the difference of our setups.

cmb69 avatar Jan 10 '22 23:01 cmb69

Make sure file is in utf-8 encoding, despite that I couldn't find single encoding which gave ones for both, several resulted with 1 for the first one and false for the second.

KapitanOczywisty avatar Jan 10 '22 23:01 KapitanOczywisty

@KapitanOczywisty, good point! I got the same results as you for Windows CP-1252. But on the other hand, the code posted in GH issues should be UTF-8 anyway, shouldn't it? Is zend.script_encoding involved?

cmb69 avatar Jan 11 '22 00:01 cmb69

I just tried it again after your comments, and realized, that in search for the real problem, i condensed the Regex to much. I added the \W back in, can you try it again on your machines? Also, the UTF-8 encoding is on for all systems. I just tested it again with the complete Regex on all systems. On windows it was version 21h2 with a fresh install using xampp-windows-x64-8.1.1-2-VS16-installer, no changes in the ini, and run from the command line to avoid issues with vscode potentially, both give int(1) back.

FlyingHelix avatar Jan 11 '22 07:01 FlyingHelix

after some more testing, it only happens on arch when running it through PHPUnit, so it does not seem to be a general PHP problem.

FlyingHelix avatar Jan 11 '22 08:01 FlyingHelix