误删Mac .lproj文件导致psql输出字符编码异常求助
Hey there, I’ve run into similar locale-related hiccups on Mac before, so let’s work through fixing this psql output issue step by step. Those <E2><94><80> sequences are actually UTF-8 byte representations of the table border characters (like ─ and │)—the problem comes from broken system locale settings after deleting those .lproj localization files, not psql itself (which is why reinstalling didn’t resolve it).
Here’s what you can try:
1. Check Terminal’s Character Encoding
First, make sure your Terminal is configured to use UTF-8, since that’s what psql relies on to render border characters correctly:
- Open Terminal, go to Terminal > Settings > Profiles
- Select your active profile, then navigate to the Advanced tab
- Under "Character Encoding", choose Unicode (UTF-8)
- Close and reopen Terminal to apply the change
2. Reset Locale Environment Variables
The deleted .lproj files likely messed up your system’s locale configuration. Let’s force UTF-8 for your shell:
- Temporary test: Run these commands in Terminal, then launch psql to see if it fixes the issue:
export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 - Permanent fix: Edit your shell config file (depending on whether you use bash or zsh):
- For zsh (default on newer Macs): Open
~/.zshrcin a text editor, add the two lines above, then runsource ~/.zshrcto apply. - For bash: Edit
~/.bash_profileor~/.bashrcinstead, then runsource ~/.bash_profile.
- For zsh (default on newer Macs): Open
3. Rebuild System Localization Cache
If adjusting locale variables alone doesn’t work, we can rebuild Mac’s localization database to fix missing .lproj-related data:
- Run this command in Terminal (you’ll need your admin password):
sudo /usr/libexec/locale-gen - Additionally, go to System Settings > General > Language & Region, drag "English" to the top of the language list, then restart your Mac. This forces the system to reload core localization settings.
4. Reset Psql’s Configuration (Optional)
If the above steps don’t help, try resetting psql’s user-specific config to rule out any custom settings interfering:
- Delete the psql config file (if it exists):
rm ~/.psqlrc - Launch psql again—it will use default output formatting settings.
After trying these steps, your psql table borders should show up as the proper │ and ─ characters instead of the garbled byte sequences.
内容的提问来源于stack exchange,提问作者MTR

