With the default settings on a Mac OS X 10.5 system, perl scripts will issue a warning that the locale has not been set properly. The warning will look similar to this:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = (unset),
LANG = "UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
To fix this issue, create a folder in you home directory called .MacOSX (if it doesn’t already exist). Create a text file in that folder, calling it environment.plist and giving it the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM
"file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>LANG</key>
<string>UTF-8</string>
<key>LC_ALL</key>
<string>C</string>
</dict>
</plist>
You then need to log out and back in again for the changes to take effect.
One reply on “Fix Perl locale warning on Mac OS X 10.5”
For some reason adding those keys to environment.plist didn’t set the corresponding environment variables for me (although setting EDITOR that way works fine), so it didn’t really fix the problem.
I ended up using the quick-and-dirty fix from http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/perllocale.1.html , that is setting PERL_BADLANG to 0 in environment.plist.