setlocale(LC_CTYPE, "de_DE.UTF8") or setlocale(LC_CTYPE, "de_DE.UTF-8")?

locale, php, utf-8

Solution

I'd run `locale -a` and use the string it outputs. On OS X 10.9, I get `de_DE.UTF-8`. On Debian 6, I get `de_DE.utf8`. `dpkg-reconfigure locales` uses `de_DE.UTF-8` on the other hand. The safest way is probably to check the return value of `setlocale` and try different variants if it fails.

That said, all versions should usually work: with or without dash, uppercase or lowercase.

Problem

``` setlocale(LC_CTYPE, "de_DE.UTF8") ``` or ``` setlocale(LC_CTYPE, "de_DE.UTF-8") ``` With or without dash? I've seen both in answers.

Original source