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

后端 未结 3 751
走了就别回头了
走了就别回头了 2020-12-19 05:46

I was trying to generate a localized date string with strftime, the placeholder I use is %x. The language/locale is setlocale(LC_ALL, array(\

相关标签:
3条回答
  • 2020-12-19 05:49

    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.

    0 讨论(0)
  • 2020-12-19 06:03

    Feasible, yes. Wise, not at all!

    0 讨论(0)
  • 2020-12-19 06:07

    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');
    
    0 讨论(0)
提交回复
热议问题