Dhiraj
Dhiraj

Reputation: 33628

Converting russian characters from upper case to lower case in php

I'm trying to change the case of russian characters from upper to lower.

 function toLower($string) {   
 echo strtr($string,'ЁЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ','ёйцукенгшщзхъфывапролджэячсмитьбю');
 };

This is the function I used and the output looks something like this

ЁЙ## ёѹ##`

Can anybody help me with this ? Thanks in advance

Upvotes: 5

Views: 6323

Answers (2)

Anne
Anne

Reputation: 27073

Specify the charset within the HTML and use mb_strtolower() to convert case:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    <head>
        <title></title>
    </head>
    <body>
<?
$string = 'ЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ' ;
echo mb_strtolower($string, 'UTF-8');
?>
    </body>
</html>

With the meta-tag it looks like this:

цукенгшщзхъфывапролджэячсмитьбю

Without the meta-tag it looks like this

цукенгшщзхъфывапролджÑÑчÑмитьбю

Upvotes: 5

zerkms
zerkms

Reputation: 255025

$result = mb_strtolower($orig, 'UTF-8');

(assuming the data is in utf-8)

Upvotes: 13

Related Questions