0

I am working on a multilingual website. I use a database and a table to get the translations for the different words and sentences.

For instance, in my menu I have an element called "Translations". So when the website is visited in German....the element will be called "Übersetzungen"

Now here comes the problem. For the rest of the special characters this problem doesn't happen. It seems to happen only with uppercase special characters like "Ü".

In the table of the database the value is "Ãbersetzungen" and in HTML printed should be "Übersetzungen".

Example of the problem

In other cases like "Länder" (countries in German), the translation returns "Länder". (contains an lowercase special character).

The UT8 is set in the header, the data is correctly inserted in the table and in all cases which contains UT8 special characters works fine, except special uppercase characters.

I am using WAMP to build my website and the php.ini has utf8 as default.

What could be the problem?

  • There are a number of elements which needs to be specified to a specific charset. There's also special multi-byte functions, like `strtoupper()` has `mb_strtoupper()` for multibyte characters. http://php.net/manual/en/function.mb-strtoupper.php – Qirel Mar 19 '17 at 13:07
  • I am not trying to convert a string to uppercase. I just wanna know why an uppercase character doesnt show properly like in the word "Übersetzungen". In the table of the database the value is "Ãbersetzungen" and in HTML printed should be "Übersetzungen". For the rest of cases this problem doesn't happen. – Imaginario27 Mar 19 '17 at 13:11
  • Oh, I misread the question then. Well, in any case, its a encoding issue. I've previously written an [**answer with a little list**](http://stackoverflow.com/questions/31897407/mysql-and-php-utf-8-with-cyrillic-characters/31899827#31899827) of what to check, this covers *most* of PHP/MySQL things to check about charset. – Qirel Mar 19 '17 at 13:28

1 Answers1

1

Try this..

https://www.php.net/manual/en/function.mb-strtoupper.php

<?php
$str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str = mb_strtoupper($str, 'UTF-8');
echo $str; // Prints ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ
?>
Fazıl Akbulut
  • 198
  • 2
  • 14