Fix detection of non UTF-8 locales