Fix an issue on OSX

OSX uses the BSD version of tr, which can fail on some inputs unless the locale is set to
C.