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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
12 + 16 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 05:01:29 2024 UTC