You are here: Re: ucfirst and utf-8; setlocale « All PHP « IT news, forums, messages
Re: ucfirst and utf-8; setlocale

Posted by Kimmo Laine on 01/12/06 15:20

"Markus Ernst" <derernst@NO#SP#AMgmx.ch> wrote in message
news:43c6502d$1_1@news.cybercity.ch...
> Hi
>
> In a multilanguage application I need the ucfirst() functionality. As this
> function is not multibyte-compatible I tried a function suggested in the
> manual:
>
> function my_mb_ucfirst($str) {
> $fc = mb_strtoupper(mb_substr($str, 0, 1));
> return $fc.mb_substr($str, 1);
> }
>
> The test:
>
> echo my_mb_ucfirst("δhnlich");
>
> prints "δhnlich". Also setlocale(LC_ALL, 'de_DE'); does not change

You could try it with passing the character encoding to the mb_strtoupper
function:

function my_mb_ucfirst($str) {
$fc = mb_strtoupper(mb_substr($str, 0, 1), 'utf-8');
return $fc.mb_substr($str, 1);
}


--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviφ
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация