Is it feasible to rely on setlocale, and rely on locales being installed? Is it feasible to rely on setlocale, and rely on locales being installed? php php

Is it feasible to rely on setlocale, and rely on locales being installed?


If my examination of setlocale() is correct, the answer is: No and no. The range of installed locales varies, as does their name, and the availability of a certain locale ultimately cannot be predicted with total certainty.


You can check the return value of setlocale and at least check that it was installed. Otherwise you will have silent failures:

setlocale(LC_ALL, 'en_US') or die('Locale not installed');