EDDYMENS

Umlaut Not Showing Properly | PHP

01: <?php 02: 03: echo strtoupper('atmosphäresch'); //ATMOSPHäRESCH (ä) 04: 05: echo mb_strtoupper('atmosphäresch'); //ATMOSPHÄRESCH 06:

Most characters are represented using a single byte in memory.

A few characters, however, are represented using multiple bytes. These are known as extended characters. This includes the umlaut alphabets for example.

PHP functions such as strtoupper used to convert strings to uppercase cannot handle multibyte characters and so most times you end up with undesired results.

Solution

PHP does provide string processing functions that can deal with multibyte characters.

For example, in the case of strtoupper the multibyte equivalent is mb_strtoupper.

Other string functions in PHP have multibyte equivalents as well. Most comprise the name of the single byte function prefixed by mb_ for the multibyte version.

You can find the list of all the multibyte functions in PHP on its official website [↗].

Here is another article you might like 😊 Contentful vs Netlify CMS which should you pick?