PHP 8.5.0 Alpha 1 available for testing

Voting

: four plus four?
(Example: nine)

The Note You're Voting On

Anonymous
19 years ago
The example from bruno dot cenou at revues dot org below shows the possibility, but I want to spell it out: you can add charset info to setlocale.

Example:

Into my utf-8-encoded page I want to insert the name of the current month, which happens to be March, in German "März" - with umlaut. If you use

setlocale(LC_TIME, 'de_DE');
echo strftime("%B");

this will return "März", but that html-entity will look like this on a utf-8 page: "M?rz". Not what I want.

But if you use

setlocale(LC_TIME, 'de_DE.UTF8'); // note the charset info !
echo strftime("%B");

this returns "M√§rz", which, on utf-8, looks like it should: "März".

<< Back to user notes page

To Top