0

I know there are a lot of other topics that are equal to this one, but it isn't.

In php there is a function called iconv. It can convert é to e or ö to o, theoretically.

Here is good example: http://php.net/manual/de/function.iconv.php#105507

Now I'm struggling at the point that I don't get the same result as in the example.

For the English or German language, doesn't matter at this point, I get Weiss, Goldmann, G"obel, Weiss, G"othe, Goethe und G"otz. The ß letter is correct converted to ss, but not the others.

I know the example is 6 years old. But what changed through the time? How do I get it right?

Mr.Tr33
  • 838
  • 2
  • 18
  • 42
  • encoding issue maybe – Cid May 25 '18 at 14:40
  • well the php file is in utf-8 – Mr.Tr33 May 25 '18 at 14:40
  • Is the server getting back UTF-8? – napolux May 25 '18 at 14:42
  • server-side encoding issue maybe, then – Cid May 25 '18 at 14:42
  • I'm using php7.2.5 with xampp, I had never encoding problems. How can I check the encoding of the server? – Mr.Tr33 May 25 '18 at 14:47
  • in the php.ini is set `default_charset="UTF-8"` – Mr.Tr33 May 25 '18 at 14:53
  • 1
    Better fix your charset issues instead. All it takes, is one wrong charset setting in your application - *everything* needs to be the same charset! I have previously written [**an answer about UTF-8 encoding**](https://stackoverflow.com/a/31899827/4535200) that contains a little checklist, that will cover *most* of the charset issues in a PHP/MySQL application. There's also a more in-depth topic, [**UTF-8 All the Way Through**](https://stackoverflow.com/q/279170/4535200). Most likely, you'll find a solution in either one or both of these topics. – Qirel May 25 '18 at 14:58
  • well the problem is that there is nothing more to change to utf-8. the file is utf-8, I'm printing it in a utf-8 console and php is set to utf-8. that is the whole problem here, I don't know anything more to do – Mr.Tr33 May 25 '18 at 15:20

1 Answers1

1

This seems to work, just like the comment:

<?php
$utf8_sentence = 'Weiß, Goldmann, Göbel, Weiss, Göthe, Goethe und Götz';
echo iconv('UTF-8', 'ASCII//TRANSLIT', $utf8_sentence);

Live demo