Check d_setlocale before calling POSIX::setlocale