php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46402 Incorrect case convertions of native letters, after using setlocale
Submitted: 2008-10-27 13:18 UTC Modified: 2008-10-27 13:39 UTC
From: kvv at nightmail dot ru Assigned:
Status: Not a bug Package: *Languages/Translation
PHP Version: 5.2.6 OS: FreeBSD 6.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kvv at nightmail dot ru
New email:
PHP Version: OS:

 

 [2008-10-27 13:18 UTC] kvv at nightmail dot ru
Description:
------------
After setting script locale to ru_RU.UTF-8, behavior of functions 
strtoupper and atrtolower becomes unpredictable. Function setlocale, 
reports that encoding is setted to desired. But case conversion make 
no changes or change letters incorrectly (results may vary).




Reproduce code:
---------------
<?php
header('Content-type: text/html; charset=utf-8');
$sL = '?????????????????????????????????'; // lower russian alphabet, source file must be in utf-8 encoding
$sU = '?????Ũ??????????????????????????'; // upper russian alphabet
echo setlocale(LC_ALL, 'ru_RU.UTF-8') .'<br>';
echo 'Lower to upper:<br>';
echo strtoupper($sL) .'<br>'; // incorrect result
echo mb_strtoupper($sL, 'utf-8') .'<br>'; // correct result, for comparsion
echo 'Upper to lower:<br>';
echo strtolower($sU) .'<br>'; // incorrect result
echo mb_strtolower($sU, 'utf-8') .'<br>'; // correct result, for comparsion
?>


Expected result:
----------------
ru_RU.UTF-8
Lower to upper:
?????Ũ??????????????????????????
?????Ũ??????????????????????????
Upper to lower:
?????????????????????????????????
?????????????????????????????????




Actual result:
--------------
ru_RU.UTF-8
Lower to upper:
?????̸??????????????????????????
?????Ũ??????????????????????????
Upper to lower:
&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;
?????????????????????????????????




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-27 13:39 UTC] jani@php.net
PHP 6 will be unicode aware (and already is). PHP 5 never will be. Please don't report same issues multiple times: Use the search BEFORE submitting bug reports!!!
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Nov 19 13:01:26 2018 UTC