Handle locales more safely.
Switch to functions.
Merge pull request #1696 from fontforge/locale_threadsafe_1

Handle locales more safely.