|
Posted by Andy Hassall on 07/08/07 11:11
On Sun, 08 Jul 2007 03:32:33 -0700, robert.szczepanski@gmail.com wrote:
>Hi everybody;
>
>I can't change polish sign to small letter.
>
>This is my php script:
>
><?php
>
> setlocale(LC_ALL, "pl_PL.UTF-8") ; //this function return
>"pl_PL.UTF-8"
> echo strtolower('?Ó?TA WODA');
>
>?>
>
>When I have executed my script
>the polish letter has still capital.
>
>The result is "?Ó?ta woda" in my firefox.
>The letter "TA WODA" change ok i.e "ta woda"
>but polish letter no change good i.e. "?Ó?" => "?Ó?". it has still the
>same.
>
>I have tried to use: "header('Content-type: text/
>html;charset=pl_PL.UTF-8'); " but
>result has still the same.
>
>Any sugestion or comment how to corrent change this sign to small
>letter I am greatly appreciated.
It looks like you're trying to use a multi-byte encoded character, in UTF-8.
strtolower and the other core PHP string functions can't handle multibyte, so
it may well be that strlower is changing the case of the string character by
character - which won't work for UTF-8, even if you've set the locale.
You might have more luck with the mbstring functions, like:
http://uk3.php.net/manual/en/function.mb-strtolower.php
Try the following:
<?php
header("Content-type: text/html; charset=utf-8");
setlocale(LC_ALL, "pl_PL.UTF-8");
// UTF-8 encoded Polish characters
$chars = array(
chr(0xC4) . chr(0x85),
chr(0xC4) . chr(0x99),
chr(0xC3) . chr(0xB3),
chr(0xC4) . chr(0x87),
chr(0xC5) . chr(0x82),
);
print "<pre>";
foreach ($chars as $c)
{
print $c;
print " strtoupper: ";
print strtoupper($c);
print " mb_strtoupper: ";
print mb_strtoupper($c, 'UTF-8');
print "<br>";
}
print "</pre>";
?>
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
[Back to original message]
|