TritonDataCenter / TritonDataCenter/pkgsrc-joyent

PHP strtolower converts UTF-8 wrong

Open
#41 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
32
Forks
28
PR merge metrics
No merged PRs in 30d

Description

Converting UTF-8 strings produces invalid characters, when a UTF-8 locale is set, otherwise they are just ignored, wich is fine.

<?php
    $t = 'ö';
    $c = strtolower($t);
    print(implode(unpack("H*", $t)) . "\t" . implode(unpack("H*", $c)) . "\n");
?>
LC_ALL="C" php test.php 
c3b6    c3b6
LC_ALL="en_US.UTF-8" php test.php 
c3b6    e3b6

In this case, it "converts" an already lowercase character, but it's the same for uppercase Umlauts, Ö(c396) will end up as e396 instead of c3b6.

It works on Linux, i do not yet know if it's a problem in Illumos or PHP.

The mb_strtolower($keywords, 'UTF-8') way works however.

Tested with:
PHP 5.3.29 (cli) (built: Jan 29 2016 19:08:29)
PHP 7.0.27 (cli) (built: Apr 8 2018 20:20:23) ( NTS )

Contributor guide

No contributing guide indexed for this repository

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 reproducing the issue with the provided test.php snippet under C and en_US.UTF-8 locales, comparing strtolower with mb_strtolower. Check whether the behavior is specific to PHP or Illumos, then identify the appropriate upstream or pkgsrc component. Done means the UTF-8 result is correct or the issue is documented with its confirmed source and scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.