-2

I use strtolower() to convert strings to lower-case. When later in the code these strings are converted from UTF-8 to ANSI (Windows-1252) using iconv(), the function fails unless the //IGNORE statement is used.

I identified the offending character as the lower-case German Umlaut ü. However, prior to the ü being used, there is an upper-case Ü, which converts just fine. The difference is that the string containing the lower-case ü has been created using strtolower().

Why does strtolower() give me inconvertible results or wrong encoding? How can this be remedied?

JJJ
  • 32,902
  • 20
  • 89
  • 102
SquareCat
  • 5,699
  • 9
  • 41
  • 75
  • didn't you post something similar already? https://stackoverflow.com/questions/47221756/iconv-how-to-detect-offending-character – Funk Forty Niner Nov 10 '17 at 12:26
  • Consider using [mb_strtolower](http://php.net/manual/en/function.mb-strtolower.php) – Andrei Nov 10 '17 at 12:27
  • I did post my other question in regard on HOW TO DETECT the offending character. Now that i have found it and found the cause of the problem, i opened a new question to find out how to fix it. Totally different things. Downvote entirely unjustified, whoever did that. @pr1nc3 – read the contents of the questions. It's not a duplicate at all. – SquareCat Nov 10 '17 at 12:31
  • 1
    @SquareCat *"Now that i have found it and found the cause of the problem,"* - Either post an answer for it to mark it as solved, or delete it. Otherwise, it's still considered as being open. – Funk Forty Niner Nov 10 '17 at 12:32
  • @Fred-ii- Go read the question + comments. I am waiting for the commenter to post his answer so i can accept it. – SquareCat Nov 10 '17 at 12:33

1 Answers1

6

Use mb_strtolower which supports multibyte chracters

// Tell the function what charset you are using as second param. 
echo mb_strtolower($str, 'UTF-8');
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Springie
  • 718
  • 5
  • 8