Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

strtolower() for unicode/multibyte strings

I have some text in a non-English/foreign language in my page, but when I try to make it lowercase, it characters are converted into black diamonds containing question marks.

$a = "Երկիր Ավելացնել"; echo $b = strtolower($a); //returns  ����� ��������� 

I've set my charset in a metatag, but this didn't fix it.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

What can I do to convert my string to lowercase without corrupting it?

like image 532
Simon Avatar asked Mar 25 '10 14:03

Simon


People also ask

What is mb_ strtolower?

Description ¶ mb_strtolower(string $string , ? string $encoding = null ): string. Returns string with all alphabetic characters converted to lowercase.

How do you lowercase in PHP?

The strtolower() function converts a string to lowercase. Note: This function is binary-safe. Related functions: strtoupper() - converts a string to uppercase.

How do you uppercase in PHP?

The strtoupper() function converts a string to uppercase. Note: This function is binary-safe. Related functions: strtolower() - converts a string to lowercase.

What is Ucfirst PHP?

The ucfirst() function converts the first character of a string to uppercase. Related functions: lcfirst() - converts the first character of a string to lowercase. ucwords() - converts the first character of each word in a string to uppercase. strtoupper() - converts a string to uppercase.


1 Answers

have your tried using mb_strtolower()?

like image 178
SteelBytes Avatar answered Sep 22 '22 21:09

SteelBytes