how to lowercase in the correct locale

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

how to lowercase in the correct locale

Post by davidklonski »

Hello

I have strings in different languages, all of them start with a capital letter (for those languages that support it).
Is there a locale-aware method to change those strings so that the first letter will be in lowercase?
The solution must be locale specific.

For example:
The string 'Écran' (Screen in English) will need to be converted to 'écran'.

thanks in advance
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try:

Code: Select all

html_entity_decode(strtolower(htmlentites($str,ENT_QUOTES)),ENT_QUOTES);
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

Post by davidklonski »

I have found the following:

Code: Select all

mb_strtolower($string, $encoding);
I needed to make sure the php_mbstring.dll was included in php.ini
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I think mine should work on machines without that extension..
Post Reply